Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Display Hyperlinks from a text file
Display Hyperlinks from a text file
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Sun 15 Oct 2006 01:02 PM (UTC) |
Message
| I want to incorporate the ability to display Hyperlinked text derived from content in a text file. For the purpose of this post, I've stripped out everything that isn't directly part of
1. open file
2. get line of text from file
3. display line
4. repeat until eof
Current alias
<aliases>
<alias
match="showlink"
enabled="y"
expand_variables="y"
send_to="12"
sequence="100"
>
<send>for line in io.lines ("link.txt") do
Hyperlink ("line")
end -- for
</send>
</alias>
</aliases>
If I replace the "Hyperlink" function with "Note" it finds the text just fine, but as it is I can only get the following error;
[string "Alias: "]:2: attempt to call global 'Hyplerlink' (a nil value)
stack traceback:
[string "Alias: "]:2: in main chunk
The first two lines of text in example link.txt file are;
("run 2s3en ","Bakery: run 2s3en Food for the hungry adventurer. ","black","red",0)
("run 2s5en ","Provisions: run 2s5en General supplies (torches, containers, etc.). ","black","red",0)
These two lines work just fine when embedded as part of an Alias that directly uses the Hyperlink function. The purpose of this is part of my happy plan to add yet more options for navigating and infomation onscreen, particularly with my maps.
Advice gratefully appreciated.
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 15 Oct 2006 08:15 PM (UTC) |
Message
| You have three problems here:
- There error says: attempt to call global 'Hyplerlink' (a nil value)
You have misspelt "Hyperlink" - although it looks OK in the alias you posted.
- You have quoted "line" here:
Hyperlink ("line")
That will merely hyperlink the word "line" not the line variable. I presume you mean:
Hyperlink (line)
- Even if you fixed that, the data from the file is just a string, so it would then be doing this:
Hyperlink ('("run 2s3en ","Bakery: run 2s3en Food for the hungry adventurer. ","black","red",0)')
If you got rid of the brackets from the start and end of each line, this would work:
-- example line
line = '"run 2s3en ","Bakery: run 2s3en Food for the hungry adventurer. ","black","red",0'
-- split at commas, feed back in as a set of arguments
Hyperlink (unpack (utils.split (line, ",")))
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #2 on Mon 16 Oct 2006 09:13 AM (UTC) |
Message
| Nick,
Thank you, the typo was inserted at post time, I did have it right in the alias. Adding the utils.split and removing the ()s as you suggested worked as well as I could hope for.
Adding hyperlinks for certain actions to my triggers, aliases and zone-note files really does me more information at every step. Is there nothing Mushclient can't do?
Thanks again. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
11,596 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top