Any C++ Pro's?
DY357LX
Playing since day 1. Still can't Comm.England Join Date: 2002-10-27 Member: 1651Members, Constellation
in Off-Topic
<div class="IPBDescription">I R Nub. (Reading LUA value from C++)</div>Let's say I want to access a LUA function/variable/value/whatever from a C++ program, is it possible and if so, how?
To be completely exact, I want to see if I can read the GetHonorCurrency() (LUA) value from World of Warcraft. (Info on the function is here: <a href="http://www.wowwiki.com/API_GetHonorCurrency" target="_blank">http://www.wowwiki.com/API_GetHonorCurrency</a> )
Obviously it's coded in LUA so I need a way to access GetHonorCurrency and the value it holds from C++.
(For the non-WoW players, this is an open/public function, it's not cheating or dodgy in anyway. WoW's 3rd party AddOns can access this function for whatever reason but obviously not alter it because it's serverside.)
Any ideas? (Without messing with ReadProcessMemory because Blizzard will probably ban me for that.)
To be completely exact, I want to see if I can read the GetHonorCurrency() (LUA) value from World of Warcraft. (Info on the function is here: <a href="http://www.wowwiki.com/API_GetHonorCurrency" target="_blank">http://www.wowwiki.com/API_GetHonorCurrency</a> )
Obviously it's coded in LUA so I need a way to access GetHonorCurrency and the value it holds from C++.
(For the non-WoW players, this is an open/public function, it's not cheating or dodgy in anyway. WoW's 3rd party AddOns can access this function for whatever reason but obviously not alter it because it's serverside.)
Any ideas? (Without messing with ReadProcessMemory because Blizzard will probably ban me for that.)
Comments
May be an API sitting around to allow what you want, but I have no idea. Way I'd approach it would be to alter a text or binary file (assuming LUA can write out to disk) and have a standalone compiled program watching that file and sleeping for a set period, reading it in or just checking the alteration/touch date and time if it's a large dataset you want to play with.
More than a bit of a kludge, with its own limitations (high cpu usage with low sleep, high hdd access, possibility of a race condition where LUA will try to write to the file while the C prog has it open and locked, inability to move data BACK from the C prog without the LUA watching for another set of changes... potentially worked mostly around with the use of a second flag/lockfile to indicate new activity) but it'd allow you to get a bit of data from a running LUA script to a running compiled C executable.
If it's a single function you want to execute when a given condition is correct in the LUA, and if you have the ability to call/run external programs within that script, could always just call the program with whatever value as a command line option, and have it return the result of whatever calculation you wanted to perform outside of LUA.
Really depends on what you actually want to DO with it.
I'm not familiar with WoW modding. But if they support intermixing of C++ and LUA addons (and a C++ addon is what you're writing), but not the direct access you need. Then you'll need to smuggle the data, but hopefully with something less severe than file i/o. Look for any place that you can write to a buffer in LUA and read from that same buffer in C++, possibly abusing the chat logs?
If they don't support C++ addons at all, you're pretty much hosed without reading process memory or abusing debug logs that get written to disk.
Thanks again.
I'm basically trying to get access to certain NS2 variables/values so I can display them on the LCD of my G15 keyboard.
(Playername, mapname, server ip, max players, current weapon that sort of thing.)
Seeing as I can't (yet - more reading to be done) call/read the NS2 LUA functions/values from C++, I wanted to have NS2 spit out this info to a text file and then have a C++ .exe that reads the text file and passes it to the keyboard LCD.
<a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=110808&st=0&gopid=1792103&#entry1792103" target="_blank">More here</a>.
You may have heard Flayra mention in the Podcast17 interview, that he too has a G15 but has no immediate plans to support it.
(Completely understandable, he's busy with NS2 etc.)
So I'm seeing if I can manage any of it... it's not going well. :-)
edit: here is some info on a lua library that provides this functionality: <a href="http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0-alpha/" target="_blank">click</a>