Kan
Kan

Reputation: 169

Lua: specify file name with variables

I'd like to specify a filename based on a different id number. How can I set different a file name according to a different id value?

id = args.bdp_id
filename = "./temp/vtx_vel%d.dat", id
print (filename)

Upvotes: 3

Views: 839

Answers (2)

user4516901
user4516901

Reputation:

You can do it like this:

filename ="./temp/vtx_vel"..id..".dat"

Upvotes: 3

Ben Grimm
Ben Grimm

Reputation: 4371

See string.format if you want to use sprintf style substitutions:

filename = string.format("./temp/vtx_vel%d.dat", id)

Upvotes: 3

Related Questions