Jump to content

How functions accessible in lua quests


Go to solution Solved by Syreldar,

Recommended Posts

Hello ,

i have a question : How functions in quests accessible ; that is mean how lua know at run time where is the finction located to execute it , i think automtically he import some thing but i don't know that , if so what is it module ?!

Ex : pc.get_level() how know where there it 

 

Second Question : How to know all variable and Functions that can be accessed directly in quests  

Link to comment
Share on other sites

  • Premium

1. sources. questlua_pc.cpp

2. quest_functions file, inside locale/xx/quest/

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

16 minutes ago, Syreldar said:

1. sources. questlua_pc.cpp

2. quest_functions file, inside locale/xx/quest/

 

thank you , but it seems you did not understand a question well , or i not define my problem well ,
i mean in my question : in every programming language you should define function first and then use it , or import some modules and use their function

but here in quests we don'd define function and not import any module that has the function pc.get_level() , but use it directly without knowing him where is the function located .

 

 

and i want to know what other function other than (pc functions) can use it directly ?

Link to comment
Share on other sites

  • Premium
  • Solution
13 minutes ago, dx11 said:

 

thank you , but it seems you did not understand a question well , or i not define my problem well ,
i mean in my question : in every programming language you should define function first and then use it , or import some modules and use their function

but here in quests we don'd define function and not import any module that has the function pc.get_level() , but use it directly without knowing him where is the function located .

 

 

and i want to know what other function other than (pc functions) can use it directly ?

It seems to me you didn't understand my answer well.

 

1. Inside your sources, there are many files in which the functions are defined. The pc.xxx functions are defined inside questlua_pc.cpp. 

E2kqWKS.png

 

qRFIBxm.png

 

ms3grXT.png

 

2. All the useable functions are listed inside quest_functions, if you add new ones, they have to be also added there, because that file also works as an automatic "includer" for global functions; which are those defined inside the sources and/or external lua files such as questlib.lua.

 

When a quest uses a determined function, the compiler looks for it inside that file. If it's not found then an error will pop up and your quest will not compile. (unless it's defined in the quest itself)

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

4 minutes ago, Syreldar said:

It seems to me you didn't understand my answer well.

 

1. Inside your sources, there are many files in which the functions are defined. The pc.xxx functions are defined inside questlua_pc.cpp.

2. All the useable functions are listed inside quest_functions.

 

so , if i want to use function in quests , that's i defined it , all what i need to define it in questlua_pc.cpp and use it in quests ? that's if define it in pc , use it like pc.myFunctionName?

Link to comment
Share on other sites

  • Premium
1 minute ago, dx11 said:

 

so , if i want to use function in quests , that's i defined it , all what i need to define it in questlua_pc.cpp and use it in quests ? that's if define it in pc , use it like pc.myFunctionName?

Read my message again, I've added examples.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Forum Moderator

Hello,

 

You can find those functions within the sources of the game. You will find various files named questlua_x.cpp. Open them, go at the very end. You will notice such lines:

 
		CQuestManager::instance().AddLuaFunctionTable("arena", arena_functions);

Thanks to those, you will easily see which functions are related to arena (registered above within the list arena_function). To use them, you will need to write :"arena.function()".

Another example with questlua_pc:

 

		CQuestManager::instance().AddLuaFunctionTable("pc", pc_functions);

 

Now, if you want to find those functions, you either have to manually check each questlua_x.cpp files or to go serverside and find the file "quest_functions". Inside you will find every registered quest functions.

  • Love 3

Gurgarath
coming soon

Link to comment
Share on other sites

1 minute ago, Gurgarath said:

Hello,

 

You can find those functions within the sources of the game. You will find various files named questlua_x.cpp. Open them, go at the very end. You will notice such lines:

 

		CQuestManager::instance().AddLuaFunctionTable("arena", arena_functions);

Thanks to those, you will easily see which functions are related to arena (registered above within the list arena_function). To use them, you will need to write :"arena.function()".

Another example with questlua_pc:

 


		CQuestManager::instance().AddLuaFunctionTable("pc", pc_functions);

 

Now, if you want to find those functions, you eaither have to manually check each questlua_x.cpp files or to go serverside and find the file "quest_functions". Inside you will find every registered quest functions.

Unfortunately, I can only choose one answer ❤️ 

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.