Jump to content

How do you get a variable into your .au3 script from a .lua file?


 Share

Recommended Posts

I've given up on pixelsearch for World of Warcraft and decided to create a simple mod for the game with a light weight simple .lua code in a folder inside the game. I tested the code and it dynamicaly updates the variable which stores my warrior rage points any where from 0 - 100.

I would like to know how to code for my .au3 script to read the variable inside the .lua script inside World of Warcraft dynamicaly every time I activate my .au3 script? I know no one is keen on writting code for n00bs but maybe small snippets and some advice to point me in the right direction could help. Thanks in advance.

Link to comment
Share on other sites

I'm not quite sure how a .lua file looks, but you should be able to read it's contents using FileRead, and then parse them (extract the variabele) using _StringBetween.

Thanks for replying but I couldn't get it to work following your advice. I can't seem to succesfully open the .lua file because it doesn't even ask for it's location just (test.txt). I put in the name of the .lua code and it returns nothing. How do I read the information inside the .lua code? I'm still stuck on this problem.

Link to comment
Share on other sites

Thanks for replying but I couldn't get it to work following your advice. I can't seem to succesfully open the .lua file because it doesn't even ask for it's location just (test.txt). I put in the name of the .lua code and it returns nothing. How do I read the information inside the .lua code? I'm still stuck on this problem.

That's absurd. If a .lua file is just text then just read it and parse it. And what does "it doesn't even ask" mean? What doesn't ask? Your script? What code did you put in to make it "ask" you anything? FileRead() just reads the file. What to do with the data after it's read is up to your script.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok after trial and error I am able to open and read the .lua file for World of Warcraft game. Here is the simple code.

$file = FileOpen("C:\World of Warcraft\Interface\AddOns\Genesis\Genesis.lua", 0)
#include <string.au3>

While 1
    $chars = FileRead($file)
Wend

FileClose($file)

I haven't been able to read the value of a variable inside the Genesis.lua code. "rage" is a variable I assigned to get the number value of UnitMana{"player") which can be any where from 0 - 100. The .lua code works fine as I tested it with my editor and saw that it dynamicaly updates "rage" with a number value. So in other words "rage" is a variable inside Genesis.lua and I need to read the "rage" variable inside my .au3 script. Here is the Genesis.lua code.

function MyAddOn_OnEvent(this, UNIT_RAGE, player)
if event=="UNIT_RAGE" then   
rage = UnitMana("player")  
else end end

local frame = CreateFrame("Frame", "MyAddOnFrame");
frame:SetScript("OnEvent", MyAddOn_OnEvent);
frame:RegisterEvent("UNIT_RAGE");

I was trying to figure out _StringBetween with no success all I got was syntax errors. I spent all day learning simple .lua code and .au3 and now I hit a roadblock. If some one can provide the code snippet for this hurdle I would be very grateful. I can apply this to all my other parts of my unfinished macro and learn by trial and error.

Link to comment
Share on other sites

Ok after trial and error I am able to open and read the .lua file for World of Warcraft game. Here is the simple code.

$file = FileOpen("C:\World of Warcraft\Interface\AddOns\Genesis\Genesis.lua", 0)
#include <string.au3>

While 1
    $chars = FileRead($file)
Wend

FileClose($file)
No, it doesn't. That just loops forever in a trapped While/WEnd loop that reads the file over and over, and never exits.

I haven't been able to read the value of a variable inside the Genesis.lua code. "rage" is a variable I assigned to get the number value of UnitMana{"player") which can be any where from 0 - 100. The .lua code works fine as I tested it with my editor and saw that it dynamicaly updates "rage" with a number value. So in other words "rage" is a variable inside Genesis.lua and I need to read the "rage" variable inside my .au3 script. Here is the Genesis.lua code.

function MyAddOn_OnEvent(this, UNIT_RAGE, player)
if event=="UNIT_RAGE" then   
rage = UnitMana("player")  
else end end

local frame = CreateFrame("Frame", "MyAddOnFrame");
frame:SetScript("OnEvent", MyAddOn_OnEvent);
frame:RegisterEvent("UNIT_RAGE");

I was trying to figure out _StringBetween with no success all I got was syntax errors. I spent all day learning simple .lua code and .au3 and now I hit a roadblock. If some one can provide the code snippet for this hurdle I would be very grateful. I can apply this to all my other parts of my unfinished macro and learn by trial and error.

This is an AutoIt forum. AutoIt does not execute .lua code. If the value you are looking for is stored in the file, then you can pull it out with AutoIt. But if you don't know where or if that value is stored in the file, or if the value is only returned by executing some .lua function, then you need to go find a .lua forum to figure that out first.

If you do know where it is stored then just say where and it will be trivial to go get it.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This is an AutoIt forum. AutoIt does not execute .lua code. If the value you are looking for is stored in the file, then you can pull it out with AutoIt. But if you don't know where or if that value is stored in the file, or if the value is only returned by executing some .lua function, then you need to go find a .lua forum to figure that out first.

If you do know where it is stored then just say where and it will be trivial to go get it.

To put it simply yes the value of "rage" is stored inside the Genesis.lua file and the value of "rage" is the value I want to read from Genesis.lua and inject it into my .au3 script. The only problem is I don't know the function or code to do this. If it takes less then a minute of your time I would you to show me so I can learn from it and apply it else where in my .au3 script. I believe this is the last hurdle I must over come to complete my .au3 script and I would be thankful if you show me the way.

Link to comment
Share on other sites

lol mate it doesn't work like that... u should try doing it differnetly...

AU3 can't read from a 'variable' of lua in use.

since blizzard (as i recall...) disabled the ability to export any data using lua [iE. filewrite / iniwrite / regwrite] u have to work around that, but honestly i can't remember how we used to do it... bah [2 years ago now :)]...

well... it's kind-of a not so easy manner to manipulate WoW so... have a good time.

P.S - Use WOWWikki it has all u need about .lua

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

lol mate it doesn't work like that... u should try doing it differnetly...

AU3 can't read from a 'variable' of lua in use.

since blizzard (as i recall...) disabled the ability to export any data using lua [iE. filewrite / iniwrite / regwrite] u have to work around that, but honestly i can't remember how we used to do it... bah [2 years ago now :)]...

well... it's kind-of a not so easy manner to manipulate WoW so... have a good time.

P.S - Use WOWWikki it has all u need about .lua

Ah crap then I'm boned! Only thing I can think of is using .xml to create frames inside the game like most other WoW mods do. Within the frame when "rage" hits a desired value like 15 rage points I can have a frame light up an icon or something then I need to resort back to pixelsearch but the innacuracy and undependability of pixelsearch is why I turned to pure .lua and .au3 in the first place.

If any one has any clever ideas on how the export or simulate exporting of values from the World of Warcraft game or .lua file I would greatly apreciate it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...