\directlua{
  function set_disc_penalty(head)
    for disc in node.traverse_id(node.id('disc'), head) do
      local val = node.has_attribute(disc, 25)
      if (val) then
         disc.penalty = val
      end
    end
    return head
  end
  callback.register('pre_linebreak_filter', set_disc_penalty)
}

\attribute 25 = 0

abc\discretionary{d}{e}{f}ghi

abc\attribute 25 = -10001\discretionary{d}{e}{f}ghi

\bye
