mirror of
				https://github.com/minetest-mods/mesecons.git
				synced 2025-11-04 04:55:26 +01:00 
			
		
		
		
	Add string.split function (#500)
This commit is contained in:
		@@ -238,6 +238,16 @@ local function safe_string_find(...)
 | 
			
		||||
	return string.find(...)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- do not allow pattern matching in string.split (see string.find for details)
 | 
			
		||||
local function safe_string_split(...)
 | 
			
		||||
	if select(5, ...) then
 | 
			
		||||
		debug.sethook() -- Clear hook
 | 
			
		||||
		error("string.split: 'sep_is_pattern' (fifth parameter) may not be used in a Luacontroller")
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return string.split(...)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function remove_functions(x)
 | 
			
		||||
	local tp = type(x)
 | 
			
		||||
	if tp == "function" then
 | 
			
		||||
@@ -507,6 +517,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
 | 
			
		||||
			reverse = string.reverse,
 | 
			
		||||
			sub = string.sub,
 | 
			
		||||
			find = safe_string_find,
 | 
			
		||||
			split = safe_string_split,
 | 
			
		||||
		},
 | 
			
		||||
		math = {
 | 
			
		||||
			abs = math.abs,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user