$\pi: X \to Y$ is a morphism of LRS, and $p \mapsto q$. If $g$ is a function vanishing at $q$, then it will pull back to a function vanishing at $p$? From Vakil's Foundations of Algebraic Geometry:

6.3.1. Definition. A locally ringed space is a ringed space $(X,\mathcal O_X)$ such that the stalks $\mathcal O_{X,p}$ are all local rings. A morphism of locally ringed spaces $\pi : X \to Y$ is a morphism of ringed spaces such that the induced map of stalks $π^\# : \mathcal O_{Y,q} \to \mathcal O_{X,p}$ sends the maximal ideal of the former into the maximal ideal of the latter (a “morphism of local rings”).

Next, Vakil writes

This means something rather concrete and intuitive: “if $p \mapsto q$, and $g$ is a function vanishing at $q$, then it will pull back to a function vanishing at $p$.”



I was confused about this for a while. At first I was thinking that if $g$ is a function vanishing at $q$, then $\pi^\#_Y: \mathcal O_Y(Y) \to \mathcal O_X(X)$ satisfies $\pi^\# (g)(p)=g(\pi(p))=g(q)=0$. But Vakil does not define the map $\pi^\#$ between sections in this way.
I came up with this next:
Suppose $g$ is a function vanishing at $q \in Y$. Then $[g, Y] \in \mathcal O_{Y,q}$ is in the maximal ideal $\mathfrak m_q$. Since $π^\# : \mathcal O_{Y,q} \to \mathcal O_{X,p}$ satisfies $\pi^\#(\mathfrak m_q) \subset \mathfrak m_p$, then $[g,Y] \mapsto [\pi^\#_Y(g), X] \in \mathfrak m_p$. So, $\pi^\#(g)$ vanishes at $p$.
Is this what is really going on?
 A: Question: "This means something rather concrete and intuitive: “if p↦q, and g is a function vanishing at q, then it will pull back to a function vanishing at p.” Is this what is really going on?"
Answer: If $(f,f^{\#}): (X, \mathcal{O}_X) \rightarrow (Y, \mathcal{O}_Y)$ is a map of locally ringed spaces there is for any point $x\in X$ a well defined induced map at the stalks
$$f^{\#}_x: \mathcal{O}_{Y,f(x)} \rightarrow \mathcal{O}_{X,x}$$
defined as follows: Given s germ $a:=(U,s)\in \mathcal{O}_Y(U)$ with $f(x)\in U$. It follows $a=0$ in the stalk at $f(x)$ iff there is an open set $f(x) \in V \subseteq U$ with $s_V=0$. The image of the element $(U,s)$ in $\mathcal{O}_{X,x}$ is the germ
$$f^{\#}_x((U,s)):= (f^{-1}(U), f^{\#}(U)(s)).$$
By definition (since it is a map of locally ringed spaces) it maps the maximal ideal $\mathfrak{m}_{f(x)}$ to $\mathfrak{m}_{x}$. Hence if a section $s\in \mathfrak{m}_{f(x)}$ it follows
$$f^{\#}_x(s) \in \mathfrak{m}_x.$$
Note: You define the stalk at $x$ as follows: $\mathcal{O}_{X,x}:=lim_{x\in U}\mathcal{O}_X(U)$.
