Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2 > Metin2 Private Server > Metin2 PServer Guides & Strategies
You last visited: Today at 12:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[How-To] Notepad++ Syntax Highlighting Metin2 Quests Lua

Discussion on [How-To] Notepad++ Syntax Highlighting Metin2 Quests Lua within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
lollo_9_1's Avatar
 
elite*gold: 100
Join Date: Jun 2009
Posts: 168
Received Thanks: 711
Arrow [How-To] Notepad++ Syntax Highlighting Metin2 Quests Lua

[How-To] Notepad++ Syntax Highlighting Metin2 Quests Lua
After a while, I found back my modded notepad++ langs.xml containing all the old metin2 lua functions in there.

It's dated 2012 (I've added the recent langs.xml lua tags few hours ago for lua 5.2 as well), but I'll update it soon with the 40k functions and mine as well. (on github)

How to "install" it?

Well, open %appdata%\Notepad++\langs.xml and replace the <Language name="lua" ...> section with this: (it doesn't allow me to use <!-- --> comments though)

After that, restart notepad++, and it's done.

Result:

Enjoy your Christmas Abione.

Note: Some people should already have tried to do so in the past, but this is the nicest way I like.
lollo_9_1 is offline  
Thanks
17 Users
Old 12/26/2016, 15:32   #2
 
lollo_9_1's Avatar
 
elite*gold: 100
Join Date: Jun 2009
Posts: 168
Received Thanks: 711
Updated on github with the 40k functions as well. (and also others used by me)



Note: Also added some dumplist examples.
lollo_9_1 is offline  
Thanks
1 User
Old 12/26/2016, 19:16   #3

 
elite*gold: 83
Join Date: Nov 2013
Posts: 2,891
Received Thanks: 2,764
Quote:
Originally Posted by lollo_9_1 View Post
Updated on github with the 40k functions as well. (and also others used by me)



Note: Also added some dumplist examples.
Here's an example how you can dump all global functions without using an lookup table
Code:
local function dumpFunctions(tbl, done, preStr)
	local functions = {}
	local done = done or {tbl}
	local preStr = preStr or ""
	
	for k, v in pairs(tbl) do
		local path = ""
		if preStr == "" then
			path = k
		else
			path = string.format("%s.%s", preStr, k)
		end
		
		if type(v) == "function" then
			table.insert(functions, path)
		elseif type(v) == "table" then
			local currentTableAlreadyDone = false
			for _, tbl in ipairs(done) do
				if tbl == v then
					currentTableAlreadyDone = true
					break
				end
			end
			
			if not currentTableAlreadyDone then
				table.insert(done, v)
				
				for _, functionName in ipairs(dumpFunctions(v, done, path)) do
					table.insert(functions, functionName)
				end
			end
		end
	end
	
	return functions
end

local functions = dumpFunctions(_G)
for _, functionName in ipairs(functions) do
	print(functionName)
end
rollback is offline  
Thanks
2 Users
Old 12/26/2016, 20:51   #4
 
lollo_9_1's Avatar
 
elite*gold: 100
Join Date: Jun 2009
Posts: 168
Received Thanks: 711
Quote:
Originally Posted by rollback View Post
Here's an example how you can dump all global functions without using an lookup table
Code:
local function dumpFunctions(tbl, done, preStr)
	local functions = {}
	local done = done or {tbl}
	local preStr = preStr or ""
	
	for k, v in pairs(tbl) do
		local path = ""
		if preStr == "" then
			path = k
		else
			path = string.format("%s.%s", preStr, k)
		end
		
		if type(v) == "function" then
			table.insert(functions, path)
		elseif type(v) == "table" then
			local currentTableAlreadyDone = false
			for _, tbl in ipairs(done) do
				if tbl == v then
					currentTableAlreadyDone = true
					break
				end
			end
			
			if not currentTableAlreadyDone then
				table.insert(done, v)
				
				for _, functionName in ipairs(dumpFunctions(v, done, path)) do
					table.insert(functions, functionName)
				end
			end
		end
	end
	
	return functions
end

local functions = dumpFunctions(_G)
for _, functionName in ipairs(functions) do
	print(functionName)
end
Don't forget to sort it before the for loop:
table.sort(functions)
The only problem doing it like this is that it will add a little of junk as well. (and we also need to separate the built-in methods from the metin2's ones)

It would be perfect for quest_functions though. It would become like this:
Code:
local function dumpFunctions(tbl, done, preStr)
	local functions = {}
	local done = done or {tbl}
	local preStr = preStr or ""

	for k, v in pairs(tbl) do
		local path = ""
		if preStr == "" then
			path = k
		else
			path = string.format("%s.%s", preStr, k)
		end

		if type(v) == "function" then
			table.insert(functions, path)
		elseif type(v) == "table" then
			local currentTableAlreadyDone = false
			for _, tbl in ipairs(done) do
				if tbl == v then
					currentTableAlreadyDone = true
					break
				end
			end

			if not currentTableAlreadyDone then
				table.insert(done, v)

				for _, functionName in ipairs(dumpFunctions(v, done, path)) do
					table.insert(functions, functionName)
				end
			end
		end
	end

	return functions
end

local functions = dumpFunctions(_G)
table.sort(functions)

local outFile = assert(io.open("quest_functions", "w"))
for _, functionName in ipairs(functions) do
	outFile:write(functionName.."\n")
end
assert(outFile:close())
lollo_9_1 is offline  
Reply


Similar Threads Similar Threads
[Mini-Release]Syntax-Highlighting für Questfiles in Notepad++
04/14/2012 - Metin2 PServer Guides & Strategies - 13 Replies
Hallo liebe Com, Ich habe mich heute mal rangesetzt und mir eine Syntax-Hervorhebungsdatei für Questfiles in Notepad++ erstellt. Einige Infos dazu: Die Quest wird zur besseren Orientierung in Blöcke eingeteilt. Wichtige Schlüsselwörter wie local, if, then, end, quest, when usw. werden blau markiert.
Eigene Funktion mit syntax highlighting?
02/23/2012 - AutoIt - 4 Replies
Hi, ich wollte fragen ob man seine eigene funktion mit syntax highlighting machen kann. Also damit sie nicht grau in SciTE ist. Und wenn ja was muss ich machen bzw. beachten... MfG Ludder231
Codebox mit Syntax Highlighting
10/05/2011 - Off Topic - 36 Replies
Hallo liebe EPvPler, mich würde interessieren, was ihr von der Idee einer Codebox inklusive Syntax Highlighting haltet. Ich habe das ganze bereits in anderen Foren gesehen und finde, dass es die Lesbarkeit von Quellcode deutlich verbessert, ohne dass man es erst in einen Editor kopieren muss, der das unterstützt. Das ganze gibt es in der Form sogar schon, allerdings nur für PHP. () Ich denke aber, dass es besser wäre, wenn man das direkt in die Codebox mit einbaut und dann optional die...
[AutoIT][Scite]Calltips und Syntax Highlighting
11/12/2010 - Coding Tutorials - 4 Replies
Eigene Calltips und eigenes Syntax Highlighting in Scite _____________________________________________ Übersicht Vorwort Ändern der Userfiles



All times are GMT +2. The time now is 12:54.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.