Read in text file
Is there a way to set a variable from a text file?
local text = io.open("file.text", "r") print(text) Text file contents: This is a test. When I load the game, "This is a test." should show, but I get nothing. Any ideas? :cool: |
You can't read or write from files beyond saved variables in WoW api.
You'll have to use saved variables and perhaps edit those externally before loading the game if that's your goal. They are in plain text and easily editable by other programs, as long as you respect the right syntax. Note that saved variables cannot be edited and read in real time outside of the game itself performing actions on them, and the changes made by the game aren't saved to file until the game is properly exited or reloaded. You won't be able to have an external program acting on them in real time during gameplay nor have the game respond to external changes made to a saved variables file. The most you can do is edit them before starting up the game, or parse them after the game is closed/reloaded. |
Quote:
|
Hmm, I was going to write currently playing songs to text file... then display that. So that isn't possible?
|
No one would want to /reload after every song lol
|
What is it needed for?
At the worst it may be possible to write a music player addon that would read the music files (this is one of the few file i/o that the WoW api allows, albeit very limited and you'd need to hardcode a list of all music file paths + keep the music files inside AddOns folder.) Then that would let you at most print the file name, because I don't think WoW api supports reading ID3 tags. If you're just wanting this for streaming or youtube videos, you're much better off using a text source on your recording program to display the music file information and doing it this way. |
I was going to create an addon that displayed the current song your listening to, maybe even say it outloud in say from your character?
How would I set the filename to a string? That may work. |
https://wow.gamepedia.com/API_PlayMusic
(Maybe PlaySoundFile too, idk) You would have a table containing all the file names for your music files, and in your function which would pick out music to play, you would insert the file name into PlayMusic, and also process it separately to remove the extension and the leading folder names, so that you could display just the actual file's name w/o its extension. All music would need to be copied into the addon's directory. You can't tell the game to blanket read all music files within the directory; all files need to have their file path added in the list in your addon's code. (If you're going to output that in chat, I recommend you at least stick to custom emotes, unless you know that the people who will be around you while you use it won't mind it. Because a custom emote is less annoying than a /say message by default.) |
Yea, that wouldn't work with spotify because the music is live, no file names... :(
|
Thank you for your help though :) I guess my addon project is a bust lol
|
WoW used to be able to access iTunes if you played on a Mac, but I seem to recall that got removed with either WoD or Legion.
If that is still possible, it was recording gameplay using QuickTime that was removed. Either way, you needed a Mac. |
For future reference...
http://www.wowinterface.com/forums/s...ad.php?t=42367 |
All times are GMT -6. The time now is 04:09 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI