 %#!luatex or euptex

\ifx\directlua\undefined\else
  \input luatexja.sty
  \def\lastnodechar{\numexpr\directlua{luatexja.pltx_composite_last_node_char()}}
\fi

\setbox0=\hbox{あ
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> 12354
\setbox0=\hbox{\unhbox0
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> 12354
\setbox0=\hbox{。
  \unskip
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> 12290
\setbox0=\hbox{\unhbox0
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> -1

\setbox0=\hbox{\tate 、%
  \unskip
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> 12289
\setbox0=\hbox{\tate\unhbox0
  \count255=\lastnodechar
  \immediate\write16{\the\count255}}% -> 65041 (LuaTeX-ja), 12289 (e-upTeX)

\bye
