-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lua
184 lines (164 loc) · 5.5 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
local helpers = require('scripts/ezlibs-scripts/helpers')
local CONFIG = require('scripts/ezlibs-scripts/ezconfig')
local eztriggers = require('scripts/ezlibs-scripts/eztriggers')
local ezcache = require('scripts/ezlibs-scripts/ezcache')
local ezencounters = require('scripts/ezlibs-scripts/ezencounters/main')
eznpcs = require('scripts/ezlibs-scripts/eznpcs/eznpcs')
local ezmemory = require('scripts/ezlibs-scripts/ezmemory')
local ezmystery = require('scripts/ezlibs-scripts/ezmystery')
local ezweather = require('scripts/ezlibs-scripts/ezweather')
local ezwarps = require('scripts/ezlibs-scripts/ezwarps/main')
if CONFIG.EZFARMS_ENABLED then
require('scripts/ezlibs-scripts/ezfarms')
end
if CONFIG.EZCHRISTMAS_ENABLED then
require('scripts/ezlibs-scripts/ezchristmas')
end
local ezcheckpoints = require('scripts/ezlibs-scripts/ezcheckpoints')
local plugins = { ezweather, eznpcs, ezmemory, ezmystery, ezwarps, ezencounters ,eztriggers}
local sfx = {
hurt = '/server/assets/ezlibs-assets/sfx/hurt.ogg',
item_get = '/server/assets/ezlibs-assets/sfx/item_get.ogg',
recover = '/server/assets/ezlibs-assets/sfx/recover.ogg',
card_error = '/server/assets/ezlibs-assets/ezfarms/card_error.ogg'
}
local custom_script_path = 'scripts/ezlibs-custom/custom'
local custom_plugin = helpers.safe_require(custom_script_path)
if custom_plugin then
plugins[#plugins + 1] = custom_plugin
end
eznpcs.load_npcs()
Net:on("battle_results", function(event)
local stats = {
health=event.health,
time=event.time,
ran=event.ran,
emotion=event.emotion,
turns=event.turns,
enemies=event.enemies,
score=event.score
}
for i, plugin in ipairs(plugins) do
if plugin.handle_battle_results then
plugin.handle_battle_results(event.player_id, stats)
end
end
end)
Net:on("shop_purchase", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_shop_purchase then
plugin.handle_shop_purchase(event.player_id, event.item_name)
end
end
end)
Net:on("shop_close", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_shop_close then
plugin.handle_shop_close(event.player_id)
end
end
end)
Net:on("custom_warp", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_custom_warp then
plugin.handle_custom_warp(event.player_id, event.object_id)
end
end
end)
Net:on("player_move", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_player_move then
plugin.handle_player_move(event.player_id, event.x, event.y, event.z)
end
end
end)
Net:on("player_request", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_player_request then
plugin.handle_player_request(event.player_id, event.data)
end
end
end)
--Pass handlers on to all the libraries we are using
Net:on("tile_interaction", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_tile_interaction then
plugin.handle_tile_interaction(event.player_id, event.x, event.y, event.z, event.button)
end
end
end)
Net:on("post_selection", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_post_selection then
plugin.handle_post_selection(event.player_id, event.post_id)
end
end
end)
Net:on("board_close", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_board_close then
plugin.handle_board_close(event.player_id)
end
end
end)
Net:on("player_avatar_change", function(event)
local details = {
texture_path=event.texture_path,
animation_path=event.animation_path,
name=event.name,
element=event.element,
max_health=event.max_health,
prevent_default=event.prevent_default
}
for i, plugin in ipairs(plugins) do
if plugin.handle_player_avatar_change then
plugin.handle_player_avatar_change(event.player_id, details)
end
end
end)
Net:on("player_join", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_player_join then
plugin.handle_player_join(event.player_id)
end
end
--Provide assets for custom events
for name, path in pairs(sfx) do
Net.provide_asset_for_player(event.player_id, path)
end
end)
Net:on("actor_interaction", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_actor_interaction then
plugin.handle_actor_interaction(event.player_id, event.actor_id, event.button)
end
end
end)
Net:on("tick", function(event)
for i, plugin in ipairs(plugins) do
if plugin.on_tick then
plugin.on_tick(event.delta_time)
end
end
end)
Net:on("player_disconnect", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_player_disconnect then
plugin.handle_player_disconnect(event.player_id)
end
end
end)
Net:on("object_interaction", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_object_interaction then
plugin.handle_object_interaction(event.player_id, event.object_id, event.button)
end
end
end)
Net:on("player_area_transfer", function(event)
for i, plugin in ipairs(plugins) do
if plugin.handle_player_transfer then
plugin.handle_player_transfer(event.player_id)
end
end
end)