ID:173365
 
In my game theres this bit of code (For a book):
(BN and T are vars..)
BN = "The Lands of Unknown.. A begginers guide"
T = {"



Blah... \icon [src]

"}

when the player Click()'s the book the following is executed:
usr << browse(src.T,"window=help")

Most of the above code was lifted from the help file and reconfigured, the \icon [src] turns up:
world.dm:133:error:src:undefined var
world.dm:133:error::expected a constant expression

Could anyone tell me how to fix this?, Where to look?, Who to pay?
Thanks in advance-

Thorg
Thorg wrote:
In my game theres this bit of code (For a book):
(BN and T are vars..)
BN = "The Lands of Unknown.. A begginers guide"
T = {"
<html>
<head><title>The Lands of Unknown.. A begginers guide:</title></head>
<body>
Blah... \icon [src]
</body>
</html> "}

when the player Click()'s the book the following is executed:
usr << browse(src.T,"window=help")

Most of the above code was lifted from the help file and reconfigured, the \icon [src] turns up:
world.dm:133:error:src:undefined var
world.dm:133:error::expected a constant expression

Could anyone tell me how to fix this?, Where to look?, Who to pay?
Thanks in advance-

Thorg

Well, normally you could just place variables in it like normal text, but since you want to put an icon in there, you need to use browse_rsc(). Also, where are you setting the T and BN variables? It seems there is no source.

~>Volte
In response to Volte
the BN and T variables belong to a turf called Bookcase, when a player searches a bookcase it spawns a new obj/book in there inventory changes the Books name to BN and the text in the book to T when the player clicks the book it displays T.
EDIT:
I've also tried to put <head><title>[BN]</head></title> instead of <head><title>The Lands of Unknown.. A begginers guide:</title></head>
world.dm:133:error:BN:invalid variable
world.dm:133:error::expected a constant expression

Thanks Volte for the browse_rsc proc help.
Thanks in advance..


-Thorg
In response to Thorg
Thorg wrote:
the BN and T variables belong to a turf called Bookcase, when a player searches a bookcase it spawns a new obj/book in there inventory changes the Books name to BN and the text in the book to T when the player clicks the book it displays T.

-Thorg

Here's a better way of doing it (if you're interested).

First, make a list variable in the bookcase, containing the paths of the books you want stored in it.

turf/Bookcase
var/list/Books=list(/obj/books/Book1,/obj/books/Book2)


Then, you set up those book objects..

obj
books
verb/Read_Book()
usr<<browse({"
<B><CENTER>
[Title]</CENTER></B><HR>
[Text]"})
var
Title
Text
Book1
Title="Testers of BYOND"
Text="This is a test."
Book2
Title="Night of the living trolls"
Text="BOO! The End."


Now that everything is set up, we alter Bookcase/New() to create the types that are in it's Books list.

turf/Bookcase
var/list/Books=list(/obj/books/Book1,/obj/books/Book2)
New()
..()
for(var/Path in Books)
Books+=new Path
Books-=Path


Tadaa. Done. Now you just need to make a verb or something to get books from it.

turf/Bookcase
var/list/Books=list(/obj/books/Book1,/obj/books/Book2)
New()
..()
for(var/Path in Books)
Books+=new Path
Books-=Path
verb/GetBook(obj/books/Book as obj in Books)
set src in oview(1)
usr<<"You get [Book.Title] from the bookcase."
Books-=Book
usr.contents+=Book



That should make handling books a lot easier. If you want to reference the book's variables in the text of the book, you need to set the variable in the book's New() procedure.

~>Volte
In response to Volte
Can i use HTML in the books text variable?

-Thorg
In response to Thorg
Thorg wrote:
Can i use HTML in the books text variable?

-Thorg

Yup. I use the normal browser window, so you can change it to a pop-up window if you want.

~>Volte
In response to Volte
Thanks a trillion Volte!

-Thorg