Lua save string to file

I started using Lua for school, and I wonder if it is possible to save a string in a txt file?

i.e

I have a line called shroomand it is equal mush.

I have a file in the same folder as the .lua file with the name output.txt.

Now I want to save the line shroomto output.txt.

Then I want to make a while loop and save the line shroomto a file every second output.txt, overwriting the contents output.txtevery time I save the line.

Is this possible in Lua? I have never used Lua before, and I'm really confused at the moment.

Thanks:)

+4
source share
1

Lua, , ; "w" , f:write(shroom) .

SO.

+5

Source: https://habr.com/ru/post/1625216/


All Articles