Custom functions

while string.find(code, "MoveForward") do
		local start, End = string.find(code, "MoveForward")
		code = string.gsub(code, "MoveForward", "MoveForwarz", 1)
		print(code)
		if string.find(code, "{", End) then
			print("{ found")
			print(string.match(code, '{(.*)}', End))
			
			local arg = string.match(code, '{(.*)}', End)
			-- Move by arg amount
		end
	end

when i have more than 1 “MoveForward{1}”,
print(string.match(code, '{(.*)}', End)) prints 1} MoveForward{1
how can i make it so it prints the arguments in the MoveForward Function

local function extractKeywords(s: string): {string}
	local keywords = {}
	for keyword in s:gmatch("MoveForward{(.-)}") do
		table.insert(keywords, keyword)
	end
	return keywords
end

local s = "MoveForward{foo} hello MoveForward{bar}"
print(extractKeywords(s)) --{"foo", "bar"}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.