In this amazing notes http://www.mathematik.uni-kl.de/~gathmann/class/alggeom-2002/main.pdf pg.75 the author exlpains roughly the idea behind the notion of an affine variety and how does affiliate with that of an affine scheme.
Now, my question has to do mostly with the remark 5.1.3 down from the definition of affine schemes. He says that for a given $f \in R$ we can see the latter as a function on $X$ in a standard sense, that is, for every $\mathcal{P} \in X$ we define $f(\mathcal{P})$ to be the value of the composition $R \rightarrow R/\mathcal{P} \rightarrow \mathbb{k}(\mathcal{P})$. That's exactly what I don't get. What kind of function is that? The values for any distinct $\mathcal{P} \in X$ has a different target. Can you please write me down explicitly what does he mean by that? I don't understand if for every $\mathcal{P} \in X$ we get something like a function $f_{\mathcal{P}}: R \rightarrow \mathbb{k}(\mathcal{P})$, or not.
P.S.
Excuse me if the latter isn't correct I'm just trying to get you what my problem is!
If $R$ is any ring then we can associate to any $f\in R$ a function
$$f:\text{Spec}(R)\to\bigsqcup_{\mathfrak{p}\in\text{Spec}(R)}k(\mathfrak{p})$$
where, of course,
$$k(\mathfrak{p})=R_\mathfrak{p}/\mathfrak{p}R_\mathfrak{p}$$
defined by $$f(\mathfrak{p})=\frac{f}{1}+\mathfrak{p}R_\mathfrak{p}\,``\text{=''}\,f\mod \mathfrak{p}$$
Note that for any two functions $f,g$ of this form we can 'add them' by declaring that $(f+g)(\mathfrak{p})$ is $f(\mathfrak{p})+g(\mathfrak{p})$ where the addition is happening in $k(\mathfrak{p})$ and multiply them in a similar way--this forms a ring. This is not shocking since
$$\left\{f\in\text{Map}\left(\text{Spec}(R),\bigsqcup_{\mathfrak{p}\in\text{Spec}(R)}k(\mathfrak{p})\right):f(\mathfrak{p})\in k(\mathfrak{p})\right\}=\prod_{\mathfrak{p}\in\text{Spec}(R)}k(\mathfrak{p})$$
and the association of an element $f\in R$ to the function is just associating it to this tuple the tuple $(f\mod\mathfrak{p})$ and the addition is just this sum.
This then gives us a a ring map
$$R\to \prod_{\mathfrak{p}\in\text{Spec}(R)}k(\mathfrak{p})\subseteq\text{Map}\left(\text{Spec}(R),\bigsqcup_{\mathfrak{p}\in\text{Spec}(R)}k(\mathfrak{p})\right)$$
which is, in general, not injective. Namely, the kernel of this map is $\text{Nil}(R)$ which contains precisely the nilpotent elements of $R$. Thus, in the case that $R$ is reduced we can faithfully think of $R$ as being a 'ring of functions on $\text{Spec}(R)$' where the functions are valued in this disjoint union space.
Here is an example of where one can clean this up a bit. Namely, let's assume that $R$ is reduced and finite type over a field $k$ (not necessarily algebraically closed). Then, for every maximal ideal $\mathfrak{m}\in\text{MaxSpec}(R)$ we know that $R/\mathfrak{m}$ is a finite extension of $k$. So, suppose that we've chosen an algebraic closure $\overline{k}$ and embeddings $k(\mathfrak{m})\hookrightarrow \overline{k}$ for all $\mathfrak{m}$. Then, we can associate to any $f\in R$ a function in
$$\left\{f\in\text{Map}\left(\text{MaxSpec}(R),\bigsqcup_{\mathfrak{m}\in\text{Spec}(R)}k(\mathfrak{m})\right):f(\mathfrak{m})\in k(\mathfrak{m})\right\} $$
which by similar ideas is a subset of
$$\prod_{\mathfrak{m}\in\text{MaxSpec}(R)}k(\mathfrak{m})\hookrightarrow \prod_{\mathfrak{m}\in\text{MaxSpec}(R)}\overline{k}=\text{Map}(\text{MaxSpec}(R),\overline{k})$$
Thus, we get a ring map
$$R\to\text{Map}(\text{MaxSpec}(R),\overline{k})$$
which, in our case, is injective. This is the usual way one thinks about an element of $R$ as being a function on the variety $\text{MaxSpec}(R)$.
Hopefully this helps.