We have write_file() that let mod authors write a string to a output file and we have remove_path that lets us delete a file/directory. I know devs are against read_file for deterministic reasons and I'm completely ok with that but can we get a copy_file function? To keep determinism working the function always returns nil so there is no way to determine if the copy succeeded or failed or what, if any, data is in the source file; other than browsing to script_output outside the game and checking manually.
This way I and others can just copy a file directly and get rid of all the heredoc + write_file() nonsense I currently have to do. This would be really helpful in exporting a bunch of static content from my mod (html, css, js, images) and then writing a small config file. Currently I have to turn each static file in to a heredoc which gets tedious when I update them and tricky when it is an image or other binary data.
Code: Select all
copy_file(source, destination[, mod_name[, by_player]])
By default, source
operate on the script_output folder just like write_file does but if you include the optional mod_name
(default is nil) then source
operates from "root" directory of the specified mod (the one where info.json is in) and destination
still goes to the script_output folder. If the source
file cannot be found it is a silent failure. If the source
is a folder then copy the entire folder to destination
is the same as by_player on write_file and other functions with the parameter.