DeltaC
DeltaC

Reputation: 13

Beginner: Lua - Basic Input output Program?

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.

Upvotes: 1

Views: 190

Answers (1)

lhf
lhf

Reputation: 72312

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

Upvotes: 1

Related Questions