Would It Be Good To Use string.split?

Example:

local Codes = {
	"FREE/2500/Zin",
	"FR33/5/Level",
}

function TryCode(FakeCode)
	
	for _,Code in pairs(Codes) do
		
		local RealCode = string.split(Code,"/")

		--[[
			RealCode[1] would be the code in the codes table
			RealCode[2] would be the amount of the reward
			RealCode[3] would be what the reward is
		]]--
		
		if RealCode[1] == FakeCode then
			
			print("Award "..RealCode[2].." "..RealCode[3].."(s)")
			
		end
		
	end
	
end


2 comments

0

me either until now, I never new string.split existed until my friend has told me. I'm just woundering if it would be any good use for something simple like this

0

This may be unconventional but: https://wiki.garrysmod.com/page/string/Split