ID:147872
 
Alright, I have a lil' problem see. I want to put a 32 by 32 pic of every turf and obj on the browser, and when you click on one pic, it sets a variable, build_type to the /turf or /obj that the picture you clicked represents. I have no idea how to begin to do this because I have no experience in HTML work, and even if anyone could give me an example of 1 pic that is put into the browser and when clicked upon it sets a variable to the type of /turf or/obj is that would be great.

Heres pretty much what im looking for:
BROWSER::
Icons

[] [] [] [] [] [] [] [tree]<-- you click this one and its
[] [] [] [] [] [] [] [] a picture of a tree. when
[] [] [] [] [] [] [] [] you click it it sets the var
[] [] [] [] [] [] [] [] build_type = /turf/tree

If someone could help me on this it would be greatly appreciated, I just don't know HTML.. =\


Alright, I realized asking for a snippet is a stupid request. How about, could anyone point me in the right direction on the forum, reference, index etc. that might be helpful to me in achieving my goal?


Trog

Check out the reference's entries for browse() and browse_rsc(). Use browse() to display the HTML page, and use browse_rsc() to copy the icons into the cache. In plain English, browse_rsc() allows browse()d pages to display images that you use browse_rsc() on; so after a usr << browse_rsc('hello.dmi') call, 'hello.dmi' will display properly in browser windows sent to usr.
In response to Crispy
Thanks crispy for pointing me in the right direction! now this is what i have:
turf
treeHTML
name = ""
icon = 'tree.dmi'
desc = "A tree."
verb/look()

usr << browse_rsc(icon, "tree.png")
usr << browse("\
<a href=BYOND://?src=\ref
[src];usr=\ref[usr]>\
<img src='tree.png' border=0></a>
[desc]")
<--- ALSO how could i put the desc under the picture instead of next to it, i tried \n but that doesnt work..
    Topic(href, hlist)

var/mob/M = locate(hlist["usr"])
if(M)
M << "You clicked [src]'s browser button!"

so i got it so it shows the tree, and when you click on it it displays "you clicked blah blah" but instead of a look verb like that.. i want to be able to have it show all of the icons i have defined, anyway i can do that?

Trog
In response to Troglodyte
ALSO how could i put the desc under the picture instead of next to it, i tried \n but that doesnt work.

Your dealing in HTML now <br> should work :). If you want to learn a little more about HTML Tash has posted a small tutorial on the bwicki for us, and of course there are many websites with in-depth HTML tutorials. :)

Sorry, but I didn't understand your other question, which usually means it was over my head anyway. :P
In response to Jnco904
Thanks.. this is what I have as of now..
turf
tree
name = ""
icon = 'tree.dmi'
desc = "tree"
Type = /turf/tree
verb/look()

usr << browse_rsc(icon, "tree.png")
usr << browse("\
<a href=BYOND://?src=\ref
[src];usr=\ref[usr]>\
<img src='tree.png' border=0></a><br><font size=1>
[desc]</font>")
ball
name = ""
icon = 'ball.dmi'
desc = "ball"
Type = /turf/ball
verb/look()

usr << browse_rsc(icon, "ball.png")
usr << browse("\
<a href=BYOND://?src=\ref
[src];usr=\ref[usr]>\
<img src='ball.png' border=0></a><br><font size=1>
[desc]</font>")

Topic(href, hlist)

var/mob/M = locate(hlist["usr"])
if(M)
M.build_type=src.Type
M<<"[src.Type]"
mob/var
build_type


i can only get one picture up at a time and not without a verb to each type, anyone have any idea how i can get them up without the verb and have multiple buttons at once ?

Trog
In response to Troglodyte
So what exactly do you want? Do you want to add items from multiple looks, instead of replacing it each time? Or do you want to just display every single one all at once?
In response to Crispy
I wish to display every single one at once, so i can choose which one to click and have that icon be the build type.

Trog
In response to Troglodyte
You need to make a list of type paths that you want in the browser window. Then loop through the list, using locate() on each type to find out what its icon is. (That is, if the type path is X then use var/turf/T=locate(X) to find a turf of that type. Then use T's icon.) As you loop through the list finding the turfs, add the icon, name and link of each one to a text var (using the HTML you want). Finally, use browse() on the text var and it'll display in the browser window. Tada!

The only thing you have to watch out for is make sure that every type of turf that you want always exists on the map; otherwise you won't be able to locate() it. It might pay to have a walled off piece of map, that nobody can ever access or see, which contains one of each buildable turf. Or you could have a single turf that's walled off and set aside, where you create each type of turf one by one; but that's kind of inefficient.

Also be careful that the icons of the turfs aren't changed from one turf of that type to another; otherwise the icon of the turf might change when you re-display the browser window! =)
In response to Crispy
Thanks a lot for explaining how it could be done crispy, I'm not surprised I couldnt think of it. =)

Trog