1

im pretty new to Lua Coding. I want to learn it as i need it for my Garrys Mod Server. I have a pretty repetitive thing to do right now, and i would like to automate the process a bit. So what i need to do is input filenames and i need an output for the Lua Code i need. I know the lua code and i have the filenames so now i would like to make a simple programm which lets me input the filename, and then it outputs the code for me:

The input is map names for Garrys mod, e.g. ttt_minecraft_mythic_b8.png

It´s a png file of the Map that gets downloaded.

Now i need it to generate the following:

resource.AddFile "materials/excl_mapvote/maps/ttt_minecraft_mythic_b8.png";

So i basically need a programm that just places the input at the end of the code.

I tried a few things which all didnt work. I deleted the code afterwards because i thought i wouldnt need it anymore. I appreciate every piece of help, do not hesitate to ask questions if you need more information.

1 Answer 1

1

This program reads lines from stdin and outputs the code for each line.

while true do
    s = io.read()
    if s==nil then break end
    print('resource.AddFile "materials/excl_mapvote/maps/'..s)
end
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this, how do i choose a file it reads from? Or can i draw a text box for entering it and a box where the output is shown?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.