Changeset 1153
- Timestamp:
- 02/10/2010 09:11:35 PM (7 months ago)
- Location:
- Trunk
- Files:
-
- 5 added
- 6 modified
-
lua/Misc/0LCF_Includes (added)
-
lua/Misc/0LCF_Includes/0LCF.lua (added)
-
lua/Misc/0LCF_Includes/LCF_Creature.lua (added)
-
lua/Misc/0LCF_Includes/LCF_Gameobject.lua (added)
-
lua/Misc/0LCF_Includes/LCF_Player.lua (added)
-
src/LuaEngine/FunctionTables.h (modified) (2 diffs)
-
src/LuaEngine/GameobjectFunctions.h (modified) (1 diff)
-
src/LuaEngine/GlobalFunctions.h (modified) (2 diffs)
-
src/LuaEngine/LUAEngine.cpp (modified) (2 diffs)
-
src/LuaEngine/LUAEngine.h (modified) (2 diffs)
-
src/LuaEngine/UnitFunctions.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Trunk/src/LuaEngine/FunctionTables.h
r1147 r1153 518 518 { "DisableTargeting", &luaUnit::DisableTargeting }, 519 519 { "IsInGroup", &luaUnit::IsInGroup }, 520 { "GetLocation", &luaUnit::GetLocation }, 520 521 { NULL, NULL }, 521 522 }; … … 615 616 { "FullCastSpellOnTarget", &luaGameObject::FullCastSpellOnTarget }, 616 617 { "CustomAnimate", &luaGameObject::CustomAnimate }, 618 { "GetLocation", &luaGameObject::GetLocation }, 617 619 { NULL, NULL }, 618 620 }; -
Trunk/src/LuaEngine/GameobjectFunctions.h
r1144 r1153 1053 1053 RET_BOOL(false); 1054 1054 } 1055 int GetLocation(lua_State * L, GameObject * ptr) 1056 { 1057 CHECK_TYPEID(TYPEID_GAMEOBJECT) 1058 1059 lua_pushnumber(L,ptr->GetPositionX()); 1060 lua_pushnumber(L,ptr->GetPositionZ()); 1061 lua_pushnumber(L,ptr->GetPositionZ()); 1062 lua_pushnumber(L,ptr->GetOrientation()); 1063 return 4; 1064 } 1055 1065 } 1056 1066 #endif -
Trunk/src/LuaEngine/GlobalFunctions.h
r1122 r1153 500 500 return 1; 501 501 } 502 503 void Register(lua_State *L) { 504 lua_pushcfunction(L, &PerformIngameSpawn); 505 lua_setglobal(L, "PerformIngameSpawn"); 506 507 lua_pushcfunction(L, &GetPlayer); 508 lua_setglobal(L, "GetPlayer"); 509 510 lua_pushcfunction(L, &GetLUAEngine); 511 lua_setglobal(L, "GetLUAEngine"); 512 513 lua_pushcfunction(L, &GetLUAEngine); 514 lua_setglobal(L, "GetLuaEngine"); 515 516 lua_pushcfunction(L, &GetLuaEngineVersion); 517 lua_setglobal(L, "GetLuaEngineVersion"); 518 519 lua_pushcfunction(L, &GetGameTime); 520 lua_setglobal(L, "GetGameTime"); 521 522 lua_pushcfunction(L, &WorldDBQuery); 523 lua_setglobal(L, "WorldDBQuery"); 524 525 lua_pushcfunction(L, &CharDBQuery); 526 lua_setglobal(L, "CharDBQuery"); 527 528 lua_pushcfunction(L, &WorldDBQueryTable); 529 lua_setglobal(L, "WorldDBQueryTable"); 530 531 lua_pushcfunction(L, &CharDBQueryTable); 532 lua_setglobal(L, "CharDBQueryTable"); 533 534 lua_pushcfunction(L, &SendWorldMessage); 535 lua_setglobal(L, "SendWorldMessage"); 536 537 lua_pushcfunction(L, &ReloadTable); 538 lua_setglobal(L, "ReloadTable"); 539 540 lua_pushcfunction(L, &ReloadLuaEngine); 541 lua_setglobal(L, "ReloadLuaEngine"); 542 543 lua_pushcfunction(L, &Rehash); 544 lua_setglobal(L, "Rehash"); 545 546 lua_pushcfunction(L, &logcol); 547 lua_setglobal(L, "logcol"); 548 549 lua_pushcfunction(L, &GetPlayersInWorld); 550 lua_setglobal(L, "GetPlayersInWorld"); 551 552 lua_pushcfunction(L, &GetArcemuRevision); 553 lua_setglobal(L, "GetArcemuRevision"); 554 555 /*lua_pushcfunction(L, &GetInstanceIdsByMap); 556 lua_setglobal(L, "GetInstanceIdsByMap");*/ 557 558 /* 559 lua_pushcfunction(L, &SendPvPCaptureMessage); 560 lua_setglobal(L, "SendPvPCaptureMessage"); 561 */ 562 lua_pushcfunction(L, &GetPlayersInMap); 563 lua_setglobal(L, "GetPlayersInMap"); 564 565 lua_pushcfunction(L, &GetPlayersInZone); 566 lua_setglobal(L, "GetPlayersInZone"); 567 568 /*lua_pushcfunction(L, &RegisterTimedEvent); 569 lua_setglobal(L, "RemoveTimedEvent");*/ 570 571 lua_pushcfunction(L, &SendMail); 572 lua_setglobal(L, "SendMail"); 573 574 lua_register(L, "GetTaxiPath", &GetTaxiPath); 575 lua_register(L, "SetDBCSpellVar", &SetDBCSpellVar); 576 lua_register(L, "GetDBCSpellVar", &GetDBCSpellVar); 502 int bit_and(lua_State *L) 503 { 504 uint32 left = CHECK_ULONG(L,1); 505 uint32 right = CHECK_ULONG(L,2); 506 lua_pushnumber(L,(left & right)); 507 return 1; 508 } 509 int bit_or(lua_State * L) 510 { 511 uint32 left = CHECK_ULONG(L,1); 512 uint32 right = CHECK_ULONG(L,2); 513 lua_pushnumber(L,(left | right)); 514 return 1; 515 } 516 int bit_xor(lua_State * L) 517 { 518 uint32 left = CHECK_ULONG(L,1); 519 uint32 right = CHECK_ULONG(L,2); 520 lua_pushnumber(L,(left ^ right)); 521 return 1; 522 } 523 int bit_not(lua_State * L) 524 { 525 uint32 left = CHECK_ULONG(L,1); 526 lua_pushnumber(L,(~left)); 527 return 1; 577 528 } 578 529 } … … 652 603 lua_register(L, "SetDBCSpellVar", &luaGlobalFunctions::SetDBCSpellVar); 653 604 lua_register(L, "GetDBCSpellVar", &luaGlobalFunctions::GetDBCSpellVar); 605 //Lua's bit instructions 606 lua_register(L, "bit_and", &luaGlobalFunctions::bit_and); 607 lua_register(L, "bit_or", &luaGlobalFunctions::bit_or); 608 lua_register(L, "bit_xor", &luaGlobalFunctions::bit_xor); 609 lua_register(L, "bit_not", &luaGlobalFunctions::bit_not); 654 610 } 655 611 #endif -
Trunk/src/LuaEngine/LUAEngine.cpp
r1144 r1153 1542 1542 LuaCreature(Creature* creature) : CreatureAIScript(creature) {}; 1543 1543 ~LuaCreature() 1544 { 1545 typedef std::multimap<uint32,LuaCreature*> CMAP; 1546 CMAP & cMap = sLuaMgr.getLuCreatureMap(); 1547 CMAP::iterator itr = cMap.find(_unit->GetEntry()); 1548 CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry()); 1549 CMAP::iterator it; 1550 for(;itr != cMap.end() && itr != itend;) 1551 { 1552 it = itr++; 1553 if(it->second != NULL && it->second == this) 1554 cMap.erase(it); 1555 } 1556 } 1544 {} 1557 1545 ARCEMU_INLINE void SetUnit(Creature * ncrc) { _unit = ncrc; } 1558 1546 void OnCombatStart(Unit* mTarget) … … 1946 1934 sLuaMgr.ExecuteCall(args); 1947 1935 RELEASE_LOCK 1936 } 1937 void Destroy() 1938 { 1939 typedef std::multimap<uint32,LuaCreature*> CMAP; 1940 CMAP & cMap = sLuaMgr.getLuCreatureMap(); 1941 CMAP::iterator itr = cMap.find(_unit->GetEntry()); 1942 CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry()); 1943 CMAP::iterator it; 1944 for(;itr != cMap.end() && itr != itend;) 1945 { 1946 it = itr++; 1947 if(it->second != NULL && it->second == this) 1948 cMap.erase(it); 1949 } 1950 delete this; 1948 1951 } 1949 1952 LuaUnitBinding * m_binding; -
Trunk/src/LuaEngine/LUAEngine.h
r1144 r1153 446 446 lua_setfield(L, metatable, "__metatable"); 447 447 448 lua_push value(L, methods);448 lua_pushcfunction(L,index); 449 449 lua_setfield(L, metatable, "__index"); 450 450 … … 558 558 sprintf(buff,"%p",obj); 559 559 } 560 static int index(lua_State * L) 561 { 562 /*Paroxysm : the table obj and the missing key are currently on the stack(index 1 & 2) */ 563 lua_getglobal(L,GetTClassName<T>()); 564 // string form of the key. 565 const char * key = lua_tostring(L,2); 566 if(lua_istable(L,-1) ) 567 { 568 lua_pushvalue(L,2); 569 lua_rawget(L,-2); 570 //If the key were looking for is not in the table, retrieve its' metatables' index value. 571 if(lua_isnil(L,-1)) 572 { 573 lua_getmetatable(L,-2); 574 if(lua_istable(L,-1) ) 575 { 576 lua_getfield(L,-1,"__index"); 577 if(lua_isfunction(L,-1) ) 578 { 579 lua_pushvalue(L,1); 580 lua_pushvalue(L,2); 581 lua_pcall(L,2,1,0); 582 } 583 else if(lua_istable(L,-1) ) 584 lua_getfield(L,-1,key); 585 else 586 lua_pushnil(L); 587 } 588 else 589 lua_pushnil(L); 590 } 591 else if(lua_istable(L,-1) ) 592 { 593 lua_pushvalue(L,2); 594 lua_rawget(L,-2); 595 } 596 } 597 else 598 lua_pushnil(L); 599 600 lua_insert(L,1); 601 lua_settop(L,1); 602 return 1; 603 } 560 604 }; 561 605 class GUID_MGR -
Trunk/src/LuaEngine/UnitFunctions.h
r1144 r1153 5912 5912 RET_BOOL(false); 5913 5913 } 5914 int GetLocation(lua_State * L, Unit * ptr) 5915 { 5916 if(ptr != NULL) 5917 { 5918 lua_pushnumber(L,ptr->GetPositionX()); 5919 lua_pushnumber(L,ptr->GetPositionY()); 5920 lua_pushnumber(L,ptr->GetPositionY()); 5921 lua_pushnumber(L,ptr->GetOrientation()); 5922 return 4; 5923 } 5924 lua_pushnil(L); 5925 return 1; 5926 } 5914 5927 } 5915 5928 #endif
![(please configure the [header_logo] section in trac.ini)](/trac/arcscripts/chrome/site/your_project_logo.png)