two problems.

(1) you dropped one of the fields in the $wrap command out.
$wrap(text, font, size, width, [word,] N)
The [word,] field, the help says its optional, but i suggest to leave it in, as removing it has caused me troubles when getting ,0 (number of lines) and ,1 (1st line),.
I always include the [word,] value being 0, or 1,

(2) and this is your main problem..
var %txt $wrap($1-,dungeon,9,530,%i)
replace with
var %txt = $wrap($1-,dungeon,9,530,%i)