questlib.lua açıp aşağıdaki kodları kaldırın.
Yabancı forumdan alıntıdır.
Bu kodu ekleyin
Yabancı forumdan alıntıdır.
Kod:
npc_index_table = { ['race'] = npc.getrace, ['empire'] = npc.get_empire, } pc_index_table = { ['weapon'] = pc.getweapon, ['level'] = pc.get_level, ['hp'] = pc.gethp, ['maxhp'] = pc.getmaxhp, ['sp'] = pc.getsp, ['maxsp'] = pc.getmaxsp, ['exp'] = pc.get_exp, ['nextexp'] = pc.get_next_exp, ['job'] = pc.get_job, ['money'] = pc.getmoney, ['gold'] = pc.getmoney, ['name'] = pc.getname, ['playtime'] = pc.getplaytime, ['leadership'] = pc.getleadership, ['empire'] = pc.getempire, ['skillgroup'] = pc.get_skill_group, ['x'] = pc.getx, ['y'] = pc.gety, ['local_x'] = pc.get_local_x, ['local_y'] = pc.get_local_y, } item_index_table = { ['vnum'] = item.get_vnum, ['name'] = item.get_name, ['size'] = item.get_size, ['count'] = item.get_count, ['type'] = item.get_type, ['sub_type'] = item.get_sub_type, ['refine_vnum'] = item.get_refine_vnum, ['level'] = item.get_level, } function npc_index(t,i) local npit = npc_index_table if npit[i] then return npit[i]() else return rawget(t,i) end end function pc_index(t,i) local pit = pc_index_table if pit[i] then return pit[i]() else return rawget(t,i) end end function item_index(t, i) local iit = item_index_table if iit[i] then return iit[i]() else return rawget(t, i) end end setmetatable(pc,{__index=pc_index}) setmetatable(npc,{__index=npc_index}) setmetatable(item,{__index=item_index})
Bu kodu ekleyin
Kod:
index_tables = { pc = { ['weapon'] = pc.getweapon, ['level'] = pc.get_level, ['hp'] = pc.gethp, ['maxhp'] = pc.getmaxhp, ['sp'] = pc.getsp, ['maxsp'] = pc.getmaxsp, ['exp'] = pc.get_exp, ['nextexp'] = pc.get_next_exp, ['job'] = pc.get_job, ['money'] = pc.getmoney, ['gold'] = pc.getmoney, ['name'] = pc.getname, ['playtime'] = pc.getplaytime, ['leadership'] = pc.getleadership, ['empire'] = pc.getempire, ['skillgroup'] = pc.get_skill_group, ['x'] = pc.getx, ['y'] = pc.gety, ['local_x'] = pc.get_local_x, ['local_y'] = pc.get_local_y, ['mapindex'] = pc.get_map_index, ['guild'] = pc.get_guild, ['sex'] = pc.get_sex, ['gmlevel'] = pc.get_gm_level, ['ip'] = pc.get_ip0, ['hwid'] = pc.get_hwid, }, npc = { ['race'] = npc.getrace, ['empire'] = npc.get_empire, ['vid'] = npc.get_vid, ['level'] = npc.get_level0, ['name'] = npc.get_name0, ['pid'] = npc.get_pid0, ['type'] = npc.get_type0, ['hwid'] = npc.get_hwid, }, item = { ['id'] = item.get_id, ['cell'] = item.get_cell, ['vnum'] = item.get_vnum, ['name'] = item.get_name, ['size'] = item.get_size, ['count'] = item.get_count, ['type'] = item.get_type, ['sub_type'] = item.get_sub_type, ['refine_vnum'] = item.get_refine_vnum, ['level'] = item.get_level, ['levellimit'] = item.get_level_limit, ['wearflag'] = item.get_wearflag0, ['antiflag'] = item.get_antiflag0, ['immuneflag'] = item.get_immuneflag0, }, q = { ['index'] = q.getcurrentquestindex, ['name'] = q.getcurrentquestname, } --add your new space } function generic_index(t, i) local it = index_tables[t] return it[i] and it[i]() or rawget(t, i) end setmetatable(pc, { __index = function(t, i) return generic_index("pc", i) end }) setmetatable(npc, { __index = function(t, i) return generic_index("npc", i) end }) setmetatable(item, { __index = function(t, i) return generic_index("item", i) end }) setmetatable(q, { __index = function(t, i) return generic_index("q", i) end }) --quest --add your new space
Questlib kütüphanesi, Metin2 sunucularında quest geliştirmelerinde büyük kolaylık sunan gelişmiş bir Lua tabanlı sistemdir. Bu kütüphane özellikle quest yönetimi ve script yazımı konularında geliştiricilere genişletilebilir yapılar sunar. Table Expansion, Questlib'in temel bileşenlerinden biridir ve questlerin daha verimli çalışmasını sağlar.
Table Expansion Nedir?
Table Expansion, Lua'nın temel veri yapısı olan tablolara yeni özellikler ve fonksiyonlar ekleyerek quest geliştirme sürecini kolaylaştırır. Metin2 sunucularında quest yazarken genellikle çok sayıda tablo işlemi yapılır. Bu işlemler doğrudan Lua standart kütüphaneleriyle yapılabilir ama Questlib'in Table Expansion[/BR] özelliği sayesinde bu işlemler daha okunaklı ve sürdürülebilir hale gelir.
Table Expansion Özellikleri
Table Expansion, tablolara eklenen bazı özel fonksiyonlar sayesinde quest[/BR] geliştiricilerinin daha az kod yazarak daha fazla iş yapmasını sağlar. Örneğin bir quest[/BR] sırasında bir oyuncunun ödül[/BR] alması gerekiyorsa, bu ödül[/BR] listesi kolayca yönetilebilir. Ayrıca timer[/BR], flag[/BR], state[/BR] gibi quest[/BR] mekanizmaları da bu yapı sayesinde daha sade hale getirilebilir.
Nasıl Kullanılır?
Table Expansion kullanmak oldukça basittir. Öncelikle Questlib kütüphanesinin doğru şekilde yüklenmiş olması gerekir. Ardından Lua dosyalarınızda tablo üzerinde doğrudan özel fonksiyonlar çağrılabilir. Örneğin bir quest[/BR] tablosuna item[/BR] ekleme veya çıkarma işlemleri bu yapıyla çok daha kolay hale gelir. Geliştiriciler, quest[/BR] içinde mob[/BR] bilgileri, NPC[/BR] etkileşimleri, trigger[/BR] durumları gibi pek çok veriyi tablolar aracılığıyla organize edebilirler.
Avantajları
Table Expansion sayesinde quest[/BR] geliştirme hızı artar. Kod okunabilirliği artar ve debug[/BR] işlemleri daha kolay hale gelir. Özellikle daily quest[/BR] veya chain quest[/BR] gibi karmaşık sistemlerde bu yapı büyük kolaylık sağlar. Ayrıca custom quest[/BR] geliştirme aşamasında da geliştiricilere esneklik sunar.
Hata Ayıklama ve Performans
Table Expansion sayesinde quest[/BR] içinde yapılan işlemler daha kontrollü olur. Hatalar daha erken yakalanabilir ve performans sorunları daha kolay çözülebilir. Flag[/BR] veya state[/BR] gibi sistemlerde oluşabilecek çakışmalar bu yapı sayesinde önlenebilir. Bu da quest[/BR] sunucusunun daha kararlı çalışmasına yardımcı olur.
Sonuç
Questlib[/BR] içindeki Table Expansion özelliği, Metin2 sunucularında quest[/BR] geliştirme konusunda çalışan geliştiriciler için oldukça faydalı bir özelliktir. Kolay kullanım, performans ve esneklik sunarak quest[/BR] sistemlerinin daha güçlü ve sürdürülebilir hale gelmesini sağlar.
Questlib library is an advanced Lua-based system that provides great convenience in quest development on Metin2 servers. This library particularly offers expandable structures for quest management and script writing. Table Expansion is one of the core components of Questlib and enables more efficient operation of quests.
What is Table Expansion?
Table Expansion enhances Lua's fundamental data structure, tables, by adding new features and functions, making quest development easier. When writing quests on Metin2 servers, numerous table operations are typically performed. These can be done with standard Lua libraries, but thanks to Table Expansion feature of Questlib, these processes become more readable and maintainable.
Features of Table Expansion
Table Expansion allows developers to accomplish more with less code through special functions added to tables. For instance, if a player needs to receive a reward during a quest, this reward list can be managed easily. Additionally, quest mechanisms such as timer, flag, state can also be simplified through this structure.
How to Use It?
Using Table Expansion is quite simple. First, ensure that the Questlib library is properly installed. Then, you can call custom functions directly on tables within your Lua files. For example, adding or removing items from a quest table becomes much easier with this structure. Developers can organize various data like mob information, NPC interactions, trigger states, etc., through tables in their quest.
Advantages
Table Expansion increases the speed of quest development. Code readability improves, and debug operations become easier. Especially in complex systems like daily quest or chain quest, this structure provides great convenience. Moreover, it offers flexibility during custom quest development.
Debugging and Performance
Thanks to Table Expansion, operations performed within a quest become more controlled. Errors can be caught earlier, and performance issues can be resolved more easily. Conflicts that may occur in systems like flag or state can be prevented with this structure, which helps the quest server operate more stably.
Conclusion
Table Expansion feature within Questlib is highly beneficial for developers working on quest development in Metin2 servers. By providing ease of use, performance, and flexibility, it ensures that quest systems become stronger and more maintainable.
