Loop through XML file to create functions
I'm new to LUA so not sure how to do it/if it's possible.
Basically, given a list of steam games, I want to have it so you can say 'steam warframe' for example, and it'll load warframe. I have the basics working like this:
actions.warframe = function () os.open("steam://rungameid/230410"); end
Would I be able to have a function that builds other functions from the XML games list? An example one is here.
Take Rollercoaster Tycoon 2 for example since it has a long name. Here is the listing:
<game> <appID> 285330 </appID> <name> <![CDATA[ RollerCoaster Tycoon 2: Triple Thrill Pack ]]> </name> ...
With the name, split it at ":", and replace any spaces with underscores, so it ends up like this:
actions.rollercoaster_tycoon_2 = function () os.open("steam://rungameid/285330"); end
I could build the list in python and copy it over, but it'd be nicer if I could have a button do it on the fly :)
This page might be useful.......
Go up one or two levels from that page to find out more about what is available..........
Thanks, though making the functions seems to be the hard bit. I've possibly hit a bit of a snag anyway, I wrote a Python function to convert it all to functions, and it doesn't seem to work at all when there are a lot of functions.
I'm going to keep playing around to see if I can figure out what exactly breaks :P
Alright fixed it, however I have another question.
How can I send voice text to a function? If I say "steam type xxxxxxxxxxxx", it says "Partial Match - Unknown: xxxxxxxxxx". I tried this but it didn't work:
actions.type = function(text) keyboard.text(text); end
As to how I fixed the problem, it just doesn't like starting with numbers or any full stops, which should have been fairly obvious to start with.
How did you fix the first problem?
I put that at the end of the last post lol. You just can't start functions with numbers (so I made the functions start with launch_), and I hadn't stripped out the full stops. Since full stops sometimes make part of the name (eg. 2.0 is said as 2 point 0), I made some variations so you can say point, dot, or nothing :)
It's still got room for improvement since I've only got my library to work on, but here is the python code if anyone is interested. It'll do stuff like strip Middle-earth Shadow of Mordor to just Shadow of Mordor, or Batman: Arkham City GOTY to just Arkham City (it'll keep the originals too, just gives you more leeway with what you can say to it). Here is my list of functions generated with that, it's obviously got a few useless ones but you get the idea.
No idea as to how you pass text to functions from the voice commands then?