C
C#•2y ago
Titi

Parsing Lua files

So I have .lua files, I simply want to be able to retrieve ande dit the values in the Lua variables toe dit them from a C# Gui application if that makes sense For example the Lua file has a variable LUA_STRING_VARIBLE = "bear" I want to be able to load and edit the file in my app to be able to change it to LUA_STRING_VARIBLE = "whale" for example. I can't figure out how to parse/read and retrieve values from variables in .lua files, I'm trying to use Nlua but I can't understand it at all
40 Replies
canton7
canton7•2y ago
Your post doesn't contain a question, which means it's less likely to get an answer What exactly have you tried, and what made you think it didn't work?
Titi
TitiOP•2y ago
I've tried using a few LUA libs and I simply can't find any functions or features to read data from the file, and they're overly complicated
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX•2y ago
Hello, how are you doing?
I have a question, if you have time.
I'm working on [something] and I'm trying to do [feature]
the goal of that [feature] is to [x] and [y] because [z]
I looked at:
* official docs which are there [link1] [link2]
* detailed articles and blog [link1] [link2]
here is what I tried based on that
* [approachA] [codeA] [results] [logs]
* [approachB] [codeB] [results] [logs]
* [approachC] [codeC] [results] [logs]
* [approachD] [codeD] [results] [logs]
(Add link to repo / PR / issue if that even exist so they could run the code)

Is that the good approach ? what would you recommend ? do you know better resource to look at ?
If you have time later today for a pairing session it would be even better so we could tackle that and possibly upcoming question
Hello, how are you doing?
I have a question, if you have time.
I'm working on [something] and I'm trying to do [feature]
the goal of that [feature] is to [x] and [y] because [z]
I looked at:
* official docs which are there [link1] [link2]
* detailed articles and blog [link1] [link2]
here is what I tried based on that
* [approachA] [codeA] [results] [logs]
* [approachB] [codeB] [results] [logs]
* [approachC] [codeC] [results] [logs]
* [approachD] [codeD] [results] [logs]
(Add link to repo / PR / issue if that even exist so they could run the code)

Is that the good approach ? what would you recommend ? do you know better resource to look at ?
If you have time later today for a pairing session it would be even better so we could tackle that and possibly upcoming question
* you don't have wait for the party to reply especially Async (tchat/forum/mail/ticket/messaging app) * you wait if you're speaking verbally, audio call / conf call / sitting 1 meter away and you're sure you're not interrupting
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
So I have .lua files, I simply want to be able to retrieve and edit the values in the Lua variables to edit them from a C# Gui application if that makes sense For example the Lua file has a variable LUA_STRING_VARIABLE = "bear" I want to be able to load and edit the file in my app to be able to change it to LUA_STRING_VARIABLE = "whale" by loading the value to a textbox in my GUI app I've tried using some of the Nlua functions but they don't return anything and are completely incomprehensible using (Lua lua = new Lua()) { bool filexists = File.Exists(extracted_filepath); // check if file exists LuaFunction loadedfile = lua.LoadFile(extracted_filepath); var outputstr = loadedfile.ToString(); var objects = lua.DoFile(extracted_filepath); var callresult = loadedfile.Call(objects); }
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
really ? It's basically like parsing json but lua format, is what I'm doing really that rare
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
I'll eventually have to do the same with XML and CPP files, I wanna edit some source files "programaticaly"
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
yeah parsing was only the first step to get it loaded to my GUI do you know any solution for this ?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
okay
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
My GUI is pulling a data from a lot of different components, I need all in one
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
can I import this to my WPF app ?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
This is gonna be a lot ahrder than expected 😄 I simply wanted a library that would do something like lueafile = lua.readfile("filepath"); string luavariable = lueafile.getdatafromvariable(variablename = "LUA_STRING_VARIABLE"); is this really alien and then same for writting, input variable name and value
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
a game interface file trying to modify game data from my GUI it's a modding tool
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
it's single player on my pc
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Anchy
Anchy•2y ago
He's referring to WoW addons which are written in LUA and are perfectly fine
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Anchy
Anchy•2y ago
we share similar servers
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Anchy
Anchy•2y ago
because the addons are on local im assuming?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Anchy
Anchy•2y ago
It's perfectly fine to be skeptical of people haha
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
well more like it's local changes that don't affect others
Anchy
Anchy•2y ago
these addons are designed to be edited and are Blizzards official modding API
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
I was simply looking for some very simple data edition like quickly changing a color or string name, I'll probably just try some plain text/regex implementation or give up, thanks for the help
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Titi
TitiOP•2y ago
someone suggested hardcoding the row names that contain the variables, prob the easiest way
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server