ID:139538
 
Code:
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?

When defining object types, for the most part, you cannot use vars or procs when you give a variable an initial value.
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:
mob
var
A = (8 * 4) ** 2
B = new /list
C = new /obj
D = list("a","b")
E = my_constant_var + 7
F = world.contents
var/const/my_constant_var = 2

You can also initialize global vars to virtually any value, but this is only with global vars.
var/my_global_var = 20 + MyProc(10)

proc/MyProc(n)
switch(rand(1,5))
if(1) return n - 5
if(2) return n + 5
else return n


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.