obj
newspaper
icon='ICONS.dmi'
icon_state="Newspaper"
name="Newspaper"
var/newspaper={"
<html>
<head><title>
[src.newsname]
</title></head>
<body>
<p>[src.headline1]
<p>[src.story1]
<p>[src.headline2]
<p>[src.story2]
<p>[src.headline3]
<p>[src.story3]
<p>[src.headline4]
<p>[src.story4]
<p>[src.headline5]
<p>[src.story5]
</body>
</html>
"}
verb/Take()
set src in orange(1)
view()<<"[usr] drops a copy of [src.newsname]."
src.loc=usr.loc
verb/Drop()
view()<<"[usr] picks up a copy of [src.newsname]."
src.loc=usr
verb/Read_Paper()
usr<<browse(src.newspaper,"window=info")
Problem description: It keeps saying that it doesn't recognize the headline1 and story1 variables. I've checked, and they're there. Can anyone help?
This is because such an initial value has to be constant for the compiler to properly understand and for your world to know exactly what value to give that object right when it's born. In your case, the compiler can't make any sense of it; you're using the src var in an object definition. But src is a proc local var... and you're not in a proc at all. Therefore, it does not exist.
There are some exceptions; you can initialize vars in object definitions using some procs and vars when the result is a constant value:
You can also initialize global vars to virtually any value, but this is only with global vars.
To solve your issue, initialize the variable in a proc, where, of course, you can properly reference vars, use dynamic values and whatnot. New() is likely appropriate.