-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathluascript.h
1368 lines (1050 loc) · 44.9 KB
/
luascript.h
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2015 Mark Samman <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FS_LUASCRIPT_H_5344B2BC907E46E3943EA78574A212D8
#define FS_LUASCRIPT_H_5344B2BC907E46E3943EA78574A212D8
#include <lua.hpp>
#if LUA_VERSION_NUM >= 502
// NOTE: Define LUA_COMPAT_ALL as a workaround if this doesn't work
#ifndef LUA_COMPAT_ALL
#ifndef LUA_COMPAT_MODULE
#define luaL_register(L, libname, l) (luaL_newlib(L, l), lua_pushvalue(L, -1), lua_setglobal(L, libname))
#endif
#define lua_equal(L, i1, i2) lua_compare(L, (i1), (i2), LUA_OPEQ)
#endif
#endif
#include "database.h"
#include "enums.h"
#include "position.h"
class Thing;
class Creature;
class Player;
class Item;
class Container;
class AreaCombat;
class Combat;
class Condition;
class Npc;
class Monster;
enum LuaVariantType_t {
VARIANT_NONE,
VARIANT_NUMBER,
VARIANT_POSITION,
VARIANT_TARGETPOSITION,
VARIANT_STRING,
};
enum LuaDataType {
LuaData_Unknown,
LuaData_Item,
LuaData_Container,
LuaData_Teleport,
LuaData_Player,
LuaData_Monster,
LuaData_Npc,
LuaData_Tile,
};
struct LuaVariant {
LuaVariant() {
type = VARIANT_NONE;
number = 0;
}
LuaVariantType_t type;
std::string text;
Position pos;
uint32_t number = 0;
};
struct LuaTimerEventDesc {
int32_t scriptId = -1;
int32_t function = -1;
std::list<int32_t> parameters;
uint32_t eventId = 0;
LuaTimerEventDesc() :
scriptId(-1), function(-1), eventId(0) {}
LuaTimerEventDesc(LuaTimerEventDesc&& other) :
scriptId(other.scriptId), function(other.function),
parameters(std::move(other.parameters)), eventId(other.eventId) {}
};
class LuaScriptInterface;
class Game;
class Npc;
class ScriptEnvironment
{
public:
ScriptEnvironment();
~ScriptEnvironment();
// non-copyable
ScriptEnvironment(const ScriptEnvironment&) = delete;
ScriptEnvironment& operator=(const ScriptEnvironment&) = delete;
void resetEnv();
void setScriptId(int32_t scriptId, LuaScriptInterface* scriptInterface) {
m_scriptId = scriptId;
m_interface = scriptInterface;
}
bool setCallbackId(int32_t callbackId, LuaScriptInterface* scriptInterface);
void setEventDesc(std::string desc) {
m_eventdesc = desc;
}
std::string getEventDesc() const {
return m_eventdesc;
}
int32_t getScriptId() const {
return m_scriptId;
}
int32_t getCallbackId() const {
return m_callbackId;
}
LuaScriptInterface* getScriptInterface() {
return m_interface;
}
void setTimerEvent() {
m_timerEvent = true;
}
void resetTimerEvent() {
m_timerEvent = false;
}
void getEventInfo(int32_t& scriptId, std::string& desc, LuaScriptInterface*& scriptInterface, int32_t& callbackId, bool& timerEvent) const;
void addTempItem(Item* item);
static void removeTempItem(Item* item);
uint32_t addThing(Thing* thing);
void insertItem(uint32_t uid, Item* item);
static DBResult_ptr getResultByID(uint32_t id);
static uint32_t addResult(DBResult_ptr res);
static bool removeResult(uint32_t id);
void setNpc(Npc* npc) {
m_curNpc = npc;
}
Npc* getNpc() const {
return m_curNpc;
}
Thing* getThingByUID(uint32_t uid);
Item* getItemByUID(uint32_t uid);
Container* getContainerByUID(uint32_t uid);
void removeItemByUID(uint32_t uid);
private:
typedef std::vector<const LuaVariant*> VariantVector;
typedef std::map<uint32_t, int32_t> StorageMap;
typedef std::map<uint32_t, DBResult_ptr> DBResultMap;
//script file id
int32_t m_scriptId;
int32_t m_callbackId;
bool m_timerEvent;
LuaScriptInterface* m_interface;
//script event desc
std::string m_eventdesc;
//local item map
uint32_t m_lastUID;
std::unordered_map<uint32_t, Item*> localMap;
//temporary item list
static std::multimap<ScriptEnvironment*, Item*> tempItems;
//result map
static uint32_t m_lastResultId;
static DBResultMap m_tempResults;
//for npc scripts
Npc* m_curNpc;
};
#define reportErrorFunc(a) reportError(__FUNCTION__, a, true)
enum ErrorCode_t {
LUA_ERROR_PLAYER_NOT_FOUND,
LUA_ERROR_CREATURE_NOT_FOUND,
LUA_ERROR_ITEM_NOT_FOUND,
LUA_ERROR_THING_NOT_FOUND,
LUA_ERROR_TILE_NOT_FOUND,
LUA_ERROR_HOUSE_NOT_FOUND,
LUA_ERROR_COMBAT_NOT_FOUND,
LUA_ERROR_CONDITION_NOT_FOUND,
LUA_ERROR_AREA_NOT_FOUND,
LUA_ERROR_CONTAINER_NOT_FOUND,
LUA_ERROR_VARIANT_NOT_FOUND,
LUA_ERROR_VARIANT_UNKNOWN,
LUA_ERROR_SPELL_NOT_FOUND,
};
class LuaScriptInterface
{
public:
explicit LuaScriptInterface(std::string interfaceName);
virtual ~LuaScriptInterface();
// non-copyable
LuaScriptInterface(const LuaScriptInterface&) = delete;
LuaScriptInterface& operator=(const LuaScriptInterface&) = delete;
virtual bool initState();
bool reInitState();
int32_t loadFile(const std::string& file, Npc* npc = nullptr);
const std::string& getFileById(int32_t scriptId);
int32_t getEvent(const std::string& eventName);
int32_t getMetaEvent(const std::string& globalName, const std::string& eventName);
static ScriptEnvironment* getScriptEnv() {
assert(m_scriptEnvIndex >= 0 && m_scriptEnvIndex < 16);
return m_scriptEnv + m_scriptEnvIndex;
}
static bool reserveScriptEnv() {
return ++m_scriptEnvIndex < 16;
}
static void resetScriptEnv() {
assert(m_scriptEnvIndex >= 0);
m_scriptEnv[m_scriptEnvIndex--].resetEnv();
}
static void reportError(const char* function, const std::string& error_desc, bool stack_trace = false);
const std::string& getInterfaceName() const {
return m_interfaceName;
}
const std::string& getLastLuaError() const {
return m_lastLuaError;
}
lua_State* getLuaState() const {
return m_luaState;
}
bool pushFunction(int32_t functionId);
static int luaErrorHandler(lua_State* L);
bool callFunction(int params);
void callVoidFunction(int params);
//push/pop common structures
static void pushThing(lua_State* L, Thing* thing);
static void pushVariant(lua_State* L, const LuaVariant& var);
static void pushString(lua_State* L, const std::string& value);
static void pushCallback(lua_State* L, int32_t callback);
static std::string popString(lua_State* L);
static int32_t popCallback(lua_State* L);
// Userdata
template<class T>
static void pushUserdata(lua_State* L, T* value)
{
T** userdata = static_cast<T**>(lua_newuserdata(L, sizeof(T*)));
*userdata = value;
}
// Metatables
static void setMetatable(lua_State* L, int32_t index, const std::string& name);
static void setWeakMetatable(lua_State* L, int32_t index, const std::string& name);
static void setItemMetatable(lua_State* L, int32_t index, const Item* item);
static void setCreatureMetatable(lua_State* L, int32_t index, const Creature* creature);
// Get
template<typename T>
inline static typename std::enable_if<std::is_enum<T>::value, T>::type
getNumber(lua_State* L, int32_t arg)
{
return static_cast<T>(static_cast<int64_t>(lua_tonumber(L, arg)));
}
template<typename T>
inline static typename std::enable_if<std::is_integral<T>::value || std::is_floating_point<T>::value, T>::type
getNumber(lua_State* L, int32_t arg)
{
return static_cast<T>(lua_tonumber(L, arg));
}
template<typename T>
static T getNumber(lua_State *L, int32_t arg, T defaultValue)
{
const auto parameters = lua_gettop(L);
if (parameters == 0 || arg > parameters) {
return defaultValue;
}
return getNumber<T>(L, arg);
}
template<class T>
static T* getUserdata(lua_State* L, int32_t arg)
{
T** userdata = getRawUserdata<T>(L, arg);
if (!userdata) {
return nullptr;
}
return *userdata;
}
template<class T>
inline static T** getRawUserdata(lua_State* L, int32_t arg)
{
return reinterpret_cast<T**>(lua_touserdata(L, arg));
}
inline static bool getBoolean(lua_State* L, int32_t arg)
{
return lua_toboolean(L, arg) != 0;
}
inline static bool getBoolean(lua_State* L, int32_t arg, bool defaultValue)
{
const auto parameters = lua_gettop(L);
if (parameters == 0 || arg > parameters) {
return defaultValue;
}
return lua_toboolean(L, arg) != 0;
}
static std::string getString(lua_State* L, int32_t arg);
static Position getPosition(lua_State* L, int32_t arg, int32_t& stackpos);
static Position getPosition(lua_State* L, int32_t arg);
static Outfit_t getOutfit(lua_State* L, int32_t arg);
static LuaVariant getVariant(lua_State* L, int32_t arg);
static Thing* getThing(lua_State* L, int32_t arg);
static Creature* getCreature(lua_State* L, int32_t arg);
static Player* getPlayer(lua_State* L, int32_t arg);
template<typename T>
static T getField(lua_State* L, int32_t arg, const std::string& key)
{
lua_getfield(L, arg, key.c_str());
return getNumber<T>(L, -1);
}
static std::string getFieldString(lua_State* L, int32_t arg, const std::string& key);
static LuaDataType getUserdataType(lua_State* L, int32_t arg);
// Is
inline static bool isNumber(lua_State* L, int32_t arg)
{
return lua_isnumber(L, arg) != 0;
}
inline static bool isString(lua_State* L, int32_t arg)
{
return lua_isstring(L, arg) != 0;
}
inline static bool isBoolean(lua_State* L, int32_t arg)
{
return lua_isboolean(L, arg);
}
inline static bool isTable(lua_State* L, int32_t arg)
{
return lua_istable(L, arg);
}
inline static bool isFunction(lua_State* L, int32_t arg)
{
return lua_isfunction(L, arg);
}
inline static bool isUserdata(lua_State* L, int32_t arg)
{
return lua_isuserdata(L, arg) != 0;
}
// Push
static void pushBoolean(lua_State* L, bool value);
static void pushPosition(lua_State* L, const Position& position, int32_t stackpos = 0);
static void pushOutfit(lua_State* L, const Outfit_t& outfit);
//
inline static void setField(lua_State* L, const char* index, lua_Number value)
{
lua_pushnumber(L, value);
lua_setfield(L, -2, index);
}
inline static void setField(lua_State* L, const char* index, const std::string& value)
{
pushString(L, value);
lua_setfield(L, -2, index);
}
static std::string escapeString(const std::string& string);
#ifndef LUAJIT_VERSION
static const luaL_Reg luaBitReg[7];
#endif
static const luaL_Reg luaConfigManagerTable[4];
static const luaL_Reg luaDatabaseTable[9];
static const luaL_Reg luaResultTable[6];
static int protectedCall(lua_State* L, int nargs, int nresults);
protected:
virtual bool closeState();
void registerFunctions();
void registerClass(const std::string& className, const std::string& baseClass, lua_CFunction newFunction = nullptr);
void registerTable(const std::string& tableName);
void registerMethod(const std::string& className, const std::string& methodName, lua_CFunction func);
void registerMetaMethod(const std::string& className, const std::string& methodName, lua_CFunction func);
void registerGlobalMethod(const std::string& functionName, lua_CFunction func);
void registerVariable(const std::string& tableName, const std::string& name, lua_Number value);
void registerGlobalVariable(const std::string& name, lua_Number value);
void registerGlobalBoolean(const std::string& name, bool value);
std::string getStackTrace(const std::string& error_desc);
static std::string getErrorDesc(ErrorCode_t code);
static bool getArea(lua_State* L, std::list<uint32_t>& list, uint32_t& rows);
//lua functions
static int luaDoCreateItem(lua_State* L);
static int luaDoCreateItemEx(lua_State* L);
static int luaDoMoveCreature(lua_State* L);
static int luaDoPlayerAddItem(lua_State* L);
static int luaDoTileAddItemEx(lua_State* L);
static int luaDoSetCreatureLight(lua_State* L);
//get item info
static int luaGetDepotId(lua_State* L);
//get creature info functions
static int luaGetPlayerFlagValue(lua_State* L);
static int luaGetCreatureCondition(lua_State* L);
static int luaGetPlayerInstantSpellInfo(lua_State* L);
static int luaGetPlayerInstantSpellCount(lua_State* L);
static int luaGetWorldTime(lua_State* L);
static int luaGetWorldLight(lua_State* L);
static int luaGetWorldUpTime(lua_State* L);
//prey system
static int luaGetPreyMonsters(lua_State* L);
//end
//type validation
static int luaIsDepot(lua_State* L);
static int luaIsMoveable(lua_State* L);
static int luaIsValidUID(lua_State* L);
//container
static int luaDoAddContainerItem(lua_State* L);
//
static int luaCreateCombatArea(lua_State* L);
static int luaDoAreaCombatHealth(lua_State* L);
static int luaDoTargetCombatHealth(lua_State* L);
//
static int luaDoAreaCombatMana(lua_State* L);
static int luaDoTargetCombatMana(lua_State* L);
static int luaDoAreaCombatCondition(lua_State* L);
static int luaDoTargetCombatCondition(lua_State* L);
static int luaDoAreaCombatDispel(lua_State* L);
static int luaDoTargetCombatDispel(lua_State* L);
static int luaDoChallengeCreature(lua_State* L);
static int luaSetCreatureOutfit(lua_State* L);
static int luaSetMonsterOutfit(lua_State* L);
static int luaSetItemOutfit(lua_State* L);
static int luaDebugPrint(lua_State* L);
static int luaIsInArray(lua_State* L);
static int luaAddEvent(lua_State* L);
static int luaStopEvent(lua_State* L);
static int luaSaveServer(lua_State* L);
static int luaCleanMap(lua_State* L);
static int luaIsInWar(lua_State* L);
static int luaGetWaypointPositionByName(lua_State* L);
static int luaSendChannelMessage(lua_State* L);
static int luaSendGuildChannelMessage(lua_State* L);
#ifndef LUAJIT_VERSION
static int luaBitNot(lua_State* L);
static int luaBitAnd(lua_State* L);
static int luaBitOr(lua_State* L);
static int luaBitXor(lua_State* L);
static int luaBitLeftShift(lua_State* L);
static int luaBitRightShift(lua_State* L);
#endif
static int luaConfigManagerGetString(lua_State* L);
static int luaConfigManagerGetNumber(lua_State* L);
static int luaConfigManagerGetBoolean(lua_State* L);
static int luaDatabaseExecute(lua_State* L);
static int luaDatabaseAsyncExecute(lua_State* L);
static int luaDatabaseStoreQuery(lua_State* L);
static int luaDatabaseAsyncStoreQuery(lua_State* L);
static int luaDatabaseEscapeString(lua_State* L);
static int luaDatabaseEscapeBlob(lua_State* L);
static int luaDatabaseLastInsertId(lua_State* L);
//static int luaDatabaseConnected(lua_State* L);
static int luaDatabaseTableExists(lua_State* L);
static int luaResultGetNumber(lua_State* L);
static int luaResultGetString(lua_State* L);
static int luaResultGetStream(lua_State* L);
static int luaResultNext(lua_State* L);
static int luaResultFree(lua_State* L);
// Userdata
static int luaUserdataCompare(lua_State* L);
// _G
static int luaIsType(lua_State* L);
static int luaRawGetMetatable(lua_State* L);
// os
static int luaSystemTime(lua_State* L);
// table
static int luaTableCreate(lua_State* L);
// Game
static int luaGameGetSpectators(lua_State* L);
static int luaGameGetPlayers(lua_State* L);
static int luaGameLoadMap(lua_State* L);
static int luaGameGetExperienceStage(lua_State* L);
static int luaGameGetMonsterCount(lua_State* L);
static int luaGameGetPlayerCount(lua_State* L);
static int luaGameGetNpcCount(lua_State* L);
static int luaGameGetTowns(lua_State* L);
static int luaGameGetHouses(lua_State* L);
static int luaGameGetMounts(lua_State* L);
static int luaGameGetOutfits(lua_State* L);
static int luaGameGetGameState(lua_State* L);
static int luaGameSetGameState(lua_State* L);
static int luaGameGetWorldType(lua_State* L);
static int luaGameSetWorldType(lua_State* L);
static int luaGameGetReturnMessage(lua_State* L);
static int luaGameCreateItem(lua_State* L);
static int luaGameCreateContainer(lua_State* L);
static int luaGameCreateMonster(lua_State* L);
static int luaGameCreateNpc(lua_State* L);
static int luaGameCreateTile(lua_State* L);
static int luaGameStartRaid(lua_State* L);
// Variant
static int luaVariantCreate(lua_State* L);
static int luaVariantGetNumber(lua_State* L);
static int luaVariantGetString(lua_State* L);
static int luaVariantGetPosition(lua_State* L);
// Position
static int luaPositionCreate(lua_State* L);
static int luaPositionAdd(lua_State* L);
static int luaPositionSub(lua_State* L);
static int luaPositionCompare(lua_State* L);
static int luaPositionGetDistance(lua_State* L);
static int luaPositionIsSightClear(lua_State* L);
static int luaPositionSendMagicEffect(lua_State* L);
static int luaPositionSendDistanceEffect(lua_State* L);
// Tile
static int luaTileCreate(lua_State* L);
static int luaTileGetPosition(lua_State* L);
static int luaTileGetGround(lua_State* L);
static int luaTileGetThing(lua_State* L);
static int luaTileGetThingCount(lua_State* L);
static int luaTileGetTopVisibleThing(lua_State* L);
static int luaTileGetTopTopItem(lua_State* L);
static int luaTileGetTopDownItem(lua_State* L);
static int luaTileGetFieldItem(lua_State* L);
static int luaTileGetItemById(lua_State* L);
static int luaTileGetItemByType(lua_State* L);
static int luaTileGetItemByTopOrder(lua_State* L);
static int luaTileGetItemCountById(lua_State* L);
static int luaTileGetBottomCreature(lua_State* L);
static int luaTileGetTopCreature(lua_State* L);
static int luaTileGetBottomVisibleCreature(lua_State* L);
static int luaTileGetTopVisibleCreature(lua_State* L);
static int luaTileGetItems(lua_State* L);
static int luaTileGetItemCount(lua_State* L);
static int luaTileGetDownItemCount(lua_State* L);
static int luaTileGetTopItemCount(lua_State* L);
static int luaTileGetCreatures(lua_State* L);
static int luaTileGetCreatureCount(lua_State* L);
static int luaTileHasProperty(lua_State* L);
static int luaTileHasFlag(lua_State* L);
static int luaTileGetThingIndex(lua_State* L);
static int luaTileQueryAdd(lua_State* L);
static int luaTileGetHouse(lua_State* L);
// NetworkMessage
static int luaNetworkMessageCreate(lua_State* L);
static int luaNetworkMessageDelete(lua_State* L);
static int luaNetworkMessageGetByte(lua_State* L);
static int luaNetworkMessageGetU16(lua_State* L);
static int luaNetworkMessageGetU32(lua_State* L);
static int luaNetworkMessageGetU64(lua_State* L);
static int luaNetworkMessageGetString(lua_State* L);
static int luaNetworkMessageGetPosition(lua_State* L);
static int luaNetworkMessageAddByte(lua_State* L);
static int luaNetworkMessageAddU16(lua_State* L);
static int luaNetworkMessageAddU32(lua_State* L);
static int luaNetworkMessageAddU64(lua_State* L);
static int luaNetworkMessageAddString(lua_State* L);
static int luaNetworkMessageAddPosition(lua_State* L);
static int luaNetworkMessageAddDouble(lua_State* L);
static int luaNetworkMessageAddItem(lua_State* L);
static int luaNetworkMessageAddItemId(lua_State* L);
static int luaNetworkMessageReset(lua_State* L);
static int luaNetworkMessageSkipBytes(lua_State* L);
static int luaNetworkMessageSendToPlayer(lua_State* L);
// ModalWindow
static int luaModalWindowCreate(lua_State* L);
static int luaModalWindowDelete(lua_State* L);
static int luaModalWindowGetId(lua_State* L);
static int luaModalWindowGetTitle(lua_State* L);
static int luaModalWindowGetMessage(lua_State* L);
static int luaModalWindowSetTitle(lua_State* L);
static int luaModalWindowSetMessage(lua_State* L);
static int luaModalWindowGetButtonCount(lua_State* L);
static int luaModalWindowGetChoiceCount(lua_State* L);
static int luaModalWindowAddButton(lua_State* L);
static int luaModalWindowAddChoice(lua_State* L);
static int luaModalWindowGetDefaultEnterButton(lua_State* L);
static int luaModalWindowSetDefaultEnterButton(lua_State* L);
static int luaModalWindowGetDefaultEscapeButton(lua_State* L);
static int luaModalWindowSetDefaultEscapeButton(lua_State* L);
static int luaModalWindowHasPriority(lua_State* L);
static int luaModalWindowSetPriority(lua_State* L);
static int luaModalWindowSendToPlayer(lua_State* L);
// Item
static int luaItemCreate(lua_State* L);
static int luaItemIsItem(lua_State* L);
static int luaItemGetParent(lua_State* L);
static int luaItemGetTopParent(lua_State* L);
static int luaItemGetId(lua_State* L);
static int luaItemClone(lua_State* L);
static int luaItemSplit(lua_State* L);
static int luaItemRemove(lua_State* L);
static int luaItemGetUniqueId(lua_State* L);
static int luaItemGetActionId(lua_State* L);
static int luaItemSetActionId(lua_State* L);
static int luaItemGetCount(lua_State* L);
static int luaItemGetCharges(lua_State* L);
static int luaItemGetFluidType(lua_State* L);
static int luaItemGetWeight(lua_State* L);
static int luaItemGetSubType(lua_State* L);
static int luaItemGetName(lua_State* L);
static int luaItemGetPluralName(lua_State* L);
static int luaItemGetArticle(lua_State* L);
static int luaItemGetPosition(lua_State* L);
static int luaItemGetTile(lua_State* L);
static int luaItemHasAttribute(lua_State* L);
static int luaItemGetAttribute(lua_State* L);
static int luaItemSetAttribute(lua_State* L);
static int luaItemRemoveAttribute(lua_State* L);
static int luaItemSerializeAttributes(lua_State* L);
static int luaItemMoveTo(lua_State* L);
static int luaItemTransform(lua_State* L);
static int luaItemDecay(lua_State* L);
static int luaItemGetDescription(lua_State* L);
static int luaItemHasProperty(lua_State* L);
// Container
static int luaContainerCreate(lua_State* L);
static int luaContainerGetContentDescription(lua_State* L);
static int luaContainerGetSize(lua_State* L);
static int luaContainerGetCapacity(lua_State* L);
static int luaContainerGetEmptySlots(lua_State* L);
static int luaContainerGetItemHoldingCount(lua_State* L);
static int luaContainerGetItemCountById(lua_State* L);
static int luaContainerGetItem(lua_State* L);
static int luaContainerHasItem(lua_State* L);
static int luaContainerAddItem(lua_State* L);
static int luaContainerAddItemEx(lua_State* L);
// Teleport
static int luaTeleportCreate(lua_State* L);
static int luaTeleportGetDestination(lua_State* L);
static int luaTeleportSetDestination(lua_State* L);
// Creature
static int luaCreatureCreate(lua_State* L);
static int luaCreatureRegisterEvent(lua_State* L);
static int luaCreatureUnregisterEvent(lua_State* L);
static int luaCreatureIsRemoved(lua_State* L);
static int luaCreatureIsCreature(lua_State* L);
static int luaCreatureIsInGhostMode(lua_State* L);
static int luaCreatureIsHealthHidden(lua_State* L);
static int luaCreatureCanSee(lua_State* L);
static int luaCreatureCanSeeCreature(lua_State* L);
static int luaCreatureGetParent(lua_State* L);
static int luaCreatureGetId(lua_State* L);
static int luaCreatureGetName(lua_State* L);
static int luaCreatureGetTarget(lua_State* L);
static int luaCreatureSetTarget(lua_State* L);
static int luaCreatureGetFollowCreature(lua_State* L);
static int luaCreatureSetFollowCreature(lua_State* L);
static int luaCreatureGetMaster(lua_State* L);
static int luaCreatureSetMaster(lua_State* L);
static int luaCreatureGetLight(lua_State* L);
static int luaCreatureSetLight(lua_State* L);
static int luaCreatureGetSpeed(lua_State* L);
static int luaCreatureGetBaseSpeed(lua_State* L);
static int luaCreatureChangeSpeed(lua_State* L);
static int luaCreatureSetDropLoot(lua_State* L);
static int luaCreatureGetPosition(lua_State* L);
static int luaCreatureGetTile(lua_State* L);
static int luaCreatureGetDirection(lua_State* L);
static int luaCreatureSetDirection(lua_State* L);
static int luaCreatureGetHealth(lua_State* L);
static int luaCreatureAddHealth(lua_State* L);
static int luaCreatureGetMaxHealth(lua_State* L);
static int luaCreatureSetMaxHealth(lua_State* L);
static int luaCreatureSetHiddenHealth(lua_State* L);
static int luaCreatureGetMana(lua_State* L);
static int luaCreatureAddMana(lua_State* L);
static int luaCreatureGetMaxMana(lua_State* L);
static int luaCreatureGetSkull(lua_State* L);
static int luaCreatureSetSkull(lua_State* L);
static int luaCreatureGetOutfit(lua_State* L);
static int luaCreatureSetOutfit(lua_State* L);
static int luaCreatureGetCondition(lua_State* L);
static int luaCreatureAddCondition(lua_State* L);
static int luaCreatureRemoveCondition(lua_State* L);
static int luaCreatureRemove(lua_State* L);
static int luaCreatureTeleportTo(lua_State* L);
static int luaCreatureSay(lua_State* L);
static int luaCreatureGetDamageMap(lua_State* L);
static int luaCreatureGetSummons(lua_State* L);
static int luaCreatureGetDescription(lua_State* L);
static int luaCreatureGetPathTo(lua_State* L);
static int luaCreatureCanMove(lua_State* L);
static int luaCreatureSetNoMove(lua_State* L);
static int luaCreatureMoveTo(lua_State* L);
// Player
static int luaPlayerGetBaseXpGain(lua_State *L);
static int luaPlayerSetBaseXpGain(lua_State *L);
static int luaPlayerGetVoucherXpBoost(lua_State *L);
static int luaPlayerSetVoucherXpBoost(lua_State *L);
static int luaPlayerGetGrindingXpBoost(lua_State *L);
static int luaPlayerSetGrindingXpBoost(lua_State *L);
static int luaPlayerGetStoreXpBoost(lua_State *L);
static int luaPlayerSetStoreXpBoost(lua_State *L);
static int luaPlayerGetStaminaXpBoost(lua_State *L);
static int luaPlayerSetStaminaXpBoost(lua_State *L);
static int luaPlayerGetIdleTime(lua_State* L);
static int luaPlayerCreate(lua_State* L);
static int luaPlayerIsPlayer(lua_State* L);
static int luaPlayerGetGuid(lua_State* L);
static int luaPlayerGetIp(lua_State* L);
static int luaPlayerGetAccountId(lua_State* L);
static int luaPlayerGetLastLoginSaved(lua_State* L);
static int luaPlayerGetLastLogout(lua_State* L);
static int luaPlayerGetAccountType(lua_State* L);
static int luaPlayerSetAccountType(lua_State* L);
static int luaPlayerGetCapacity(lua_State* L);
static int luaPlayerSetCapacity(lua_State* L);
static int luaPlayerGetKills(lua_State* L);
static int luaPlayerSetKills(lua_State* L);
static int luaPlayerGetFreeCapacity(lua_State* L);
static int luaPlayerGetReward(lua_State* L);
static int luaPlayerRemoveReward(lua_State* L);
static int luaPlayerGetRewardList(lua_State* L);
static int luaPlayerGetDepotChest(lua_State* L);
static int luaPlayerGetInbox(lua_State* L);
static int luaPlayerGetSkullTime(lua_State* L);
static int luaPlayerSetSkullTime(lua_State* L);
static int luaPlayerGetDeathPenalty(lua_State* L);
static int luaPlayerGetExperience(lua_State* L);
static int luaPlayerAddExperience(lua_State* L);
static int luaPlayerRemoveExperience(lua_State* L);
static int luaPlayerGetLevel(lua_State* L);
static int luaPlayerGetMagicLevel(lua_State* L);
static int luaPlayerGetBaseMagicLevel(lua_State* L);
static int luaPlayerSetMaxMana(lua_State* L);
static int luaPlayerGetManaSpent(lua_State* L);
static int luaPlayerAddManaSpent(lua_State* L);
static int luaPlayerGetSkillLevel(lua_State* L);
static int luaPlayerGetEffectiveSkillLevel(lua_State* L);
static int luaPlayerGetSkillPercent(lua_State* L);
static int luaPlayerGetSkillTries(lua_State* L);
static int luaPlayerAddSkillTries(lua_State* L);
static int luaPlayerAddOfflineTrainingTime(lua_State* L);
static int luaPlayerGetOfflineTrainingTime(lua_State* L);
static int luaPlayerRemoveOfflineTrainingTime(lua_State* L);
static int luaPlayerAddOfflineTrainingTries(lua_State* L);
static int luaPlayerGetOfflineTrainingSkill(lua_State* L);
static int luaPlayerSetOfflineTrainingSkill(lua_State* L);
static int luaPlayerGetItemCount(lua_State* L);
static int luaPlayerGetItemById(lua_State* L);
static int luaPlayerGetVocation(lua_State* L);
static int luaPlayerSetVocation(lua_State* L);
static int luaPlayerGetSex(lua_State* L);
static int luaPlayerSetSex(lua_State* L);
static int luaPlayerGetTown(lua_State* L);
static int luaPlayerSetTown(lua_State* L);
static int luaPlayerGetGuild(lua_State* L);
static int luaPlayerSetGuild(lua_State* L);
static int luaPlayerGetGuildLevel(lua_State* L);
static int luaPlayerSetGuildLevel(lua_State* L);
static int luaPlayerGetGuildNick(lua_State* L);
static int luaPlayerSetGuildNick(lua_State* L);
static int luaPlayerGetGroup(lua_State* L);
static int luaPlayerSetGroup(lua_State* L);
static int luaPlayerGetStamina(lua_State* L);
static int luaPlayerSetStamina(lua_State* L);
//prey system
static int luaPlayerGetPreyStamina(lua_State* L);
static int luaPlayerGetPreyType(lua_State* L);
static int luaPlayerGetPreyValue(lua_State* L);
static int luaPlayerGetPreyName(lua_State* L);
static int luaPlayerSetPreyStamina(lua_State* L);
static int luaPlayerSetPreyType(lua_State* L);
static int luaPlayerSetPreyValue(lua_State* L);
static int luaPlayerSetPreyName(lua_State* L);
//end
static int luaPlayerGetSoul(lua_State* L);
static int luaPlayerAddSoul(lua_State* L);
static int luaPlayerGetMaxSoul(lua_State* L);
static int luaPlayerGetBankBalance(lua_State* L);
static int luaPlayerSetBankBalance(lua_State* L);
static int luaPlayerGetStorageValue(lua_State* L);
static int luaPlayerSetStorageValue(lua_State* L);
static int luaPlayerAddItem(lua_State* L);
static int luaPlayerAddItemEx(lua_State* L);
static int luaPlayerRemoveItem(lua_State* L);
static int luaPlayerGetMoney(lua_State* L);
static int luaPlayerAddMoney(lua_State* L);
static int luaPlayerRemoveMoney(lua_State* L);
static int luaPlayerShowTextDialog(lua_State* L);
static int luaPlayerSendTextMessage(lua_State* L);
static int luaPlayerSendChannelMessage(lua_State* L);
static int luaPlayerSendPrivateMessage(lua_State* L);
static int luaPlayerChannelSay(lua_State* L);
static int luaPlayerOpenChannel(lua_State* L);
static int luaPlayerGetSlotItem(lua_State* L);
static int luaPlayerGetParty(lua_State* L);
static int luaPlayerAddOutfit(lua_State* L);
static int luaPlayerAddOutfitAddon(lua_State* L);
static int luaPlayerRemoveOutfit(lua_State* L);
static int luaPlayerRemoveOutfitAddon(lua_State* L);
static int luaPlayerHasOutfit(lua_State* L);
static int luaPlayerSendOutfitWindow(lua_State* L);
static int luaPlayerAddMount(lua_State* L);
static int luaPlayerRemoveMount(lua_State* L);
static int luaPlayerHasMount(lua_State* L);
static int luaPlayerGetPremiumDays(lua_State* L);
static int luaPlayerAddPremiumDays(lua_State* L);
static int luaPlayerRemovePremiumDays(lua_State* L);
static int luaPlayerHasBlessing(lua_State* L);
static int luaPlayerAddBlessing(lua_State* L);
static int luaPlayerRemoveBlessing(lua_State* L);
static int luaPlayerCanLearnSpell(lua_State* L);
static int luaPlayerLearnSpell(lua_State* L);
static int luaPlayerForgetSpell(lua_State* L);
static int luaPlayerHasLearnedSpell(lua_State* L);
static int luaPlayerSendTutorial(lua_State* L);
static int luaPlayerAddMapMark(lua_State* L);
static int luaPlayerSave(lua_State* L);
static int luaPlayerPopupFYI(lua_State* L);