function Replica.SetValue(h,L,a)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local u=type(L)=="\115\116\114\105\110\103"and StringPathToArray(L)or L ReplicaSetValue(h.Id,u,a)end function Replica.SetValues(h,L,a)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local u=type(L)=="\115\116\114\105\110\103"and StringPathToArray(L)or L ReplicaSetValues(h.Id,u,a)end function Replica.ArrayInsert(h,L,a)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local u=type(L)=="\115\116\114\105\110\103"and StringPathToArray(L)or L return ReplicaArrayInsert(h.Id,u,a)end function Replica.ArraySet(u,L,a,h)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local B=type(L)=="\115\116\114\105\110\103"and StringPathToArray(L)or L ReplicaArraySet(u.Id,B,a,h)end function Replica.ArrayRemove(h,L,a)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local u=type(L)=="\115\116\114\105\110\103"and StringPathToArray(L)or L return ReplicaArrayRemove(h.Id,u,a)end function Replica.Write(a,L,...)if WriteFunctionFlag==false then error(SETTINGS.SetterError)end local h=a._write_lib_dictionary[L]local u=table.pack(a._write_lib[h](a,...))local B=a._function_listeners[h]if B~=nil then for L,a in ipairs(B)do a(...)end end return table.unpack(u)end
-- Write function setters: (Calling outside a write function will throw an error)

function Replica:SetValue(path, value)
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local path_array = (type(path) == "string") and StringPathToArray(path) or path
	ReplicaSetValue(self.Id, path_array, value)
end

function Replica:SetValues(path, values)
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local path_array = (type(path) == "string") and StringPathToArray(path) or path
	ReplicaSetValues(self.Id, path_array, values)
end

function Replica:ArrayInsert(path, value) --> new_index
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local path_array = (type(path) == "string") and StringPathToArray(path) or path
	return ReplicaArrayInsert(self.Id, path_array, value)
end

function Replica:ArraySet(path, index, value)
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local path_array = (type(path) == "string") and StringPathToArray(path) or path
	ReplicaArraySet(self.Id, path_array, index, value)
end

function Replica:ArrayRemove(path, index) --> removed_value
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local path_array = (type(path) == "string") and StringPathToArray(path) or path
	return ReplicaArrayRemove(self.Id, path_array, index)
end

function Replica:Write(function_name, ...) --> return_params...
	if WriteFunctionFlag == false then
		error(SETTINGS.SetterError)
	end
	local func_id = self._write_lib_dictionary[function_name]
	local return_params = table.pack(self._write_lib[func_id](self, ...))
	-- Signaling listeners:
	local listeners = self._function_listeners[func_id]
	if listeners ~= nil then
		for _, listener in ipairs(listeners) do
			listener(...)
		end
	end
	return table.unpack(return_params)
end
