ID:2078609
 
(See the best response by Nadrew.)
Hello!

I have some very, very basic knowledge of lists, but I cannot find any examples or tutorials about what I currently need (Or is it just that I don't understand them...), so I'll try to explain my best on what I'm trying to make, and hopefully learn a bit more about how to use lists!

I need to make a list that topic links can access them and use specific information out of each one of entries inside that list.


First things first:
I need a list with two values, which I have no idea how to make. "name" and "data", where topic name will be the "name" of the entry, and "dat" will show the text in a popup when I click on that link.

I can only assume that it can look something like this:
var/list/logs = list(
"Research Log I" = "This log I is very nice looking!",
"Research Log II" = "This log II is very nice looking!",
"Research Log III" = "This log III is very nice looking!",
"Research Log IV" = "This log IV is very nice looking!",
"Research Log V" = "This log V is very nice looking!"
)


Then, when the New() proc is called

Loop trough the list and add specific information from each one of them to dat variable

for(var/i, i < logs.len,i++) // Is this even the correct way to do it?
dat += "<a href=?[i]>[i]-[First argument of the entry (In this case, Research Log I...V)]</a><br>


And, at last, how can I set it so it automatically checks for topic name so I don't have to specify every single one, for every single log.

In Topic():
    if ([Something to identify which log I picked, maybe something with i?] in href_list)
data = "<b>[First entry argument(Research Log V)]</b><br><br>[Second entry argument(This log V is very nice looking!)]"
data += "<br><br>[topic_link(src,"return","Return")]"



At the end, it should look something like this when a popup is open:
1 - Research Log I*               <--- Those are clickable links
2 - Research Log II
3 - Research Log III
4 - Research Log IV
5 - Research Log V

And when I click on, lets say, Research Log V, a new popup is open with this:
<b>Research Log V</b>

This log V is very nice looking!
return <-- Topic link


So, that is it. I could use some help with this.
If you have any questions, or need me to better explain some parts, please ask away.

Thanks! :)
Best response
First you'd want to generate you links using for(), you don't need the three-argument format of it, BYOND has list iteration cooked right into for()

for(var/I in my_list)
src << I


Will display all of the indexs in the list.

for(var/I in my_list)
src << "[I] = [my_list[I]]"


That will show the indexes and their associated value.

So your question comes down to both iterating through the list and displaying the associated value. For your links you could do something as simple as

<a href="byond://?show_help=[I]">[I]</a>


With the client/Topic() setup along the lines of.

client/Topic(href,href_list[])
if(href && href_list)
if(href_list["show_help"])
var/help_topic = href_list["show_help"]
usr << browse(logs[help_topic],"window=help")


Note: This was all written off the top of my head to point you in the right direction and shouldn't be expected to work or even compile.
Thanks for your help!
I'll test it out and see where it goes.
Works perfectly. Thanks Nadrew!