๐Ÿงฉ IO Guide

July 25, 2025 ยท View on GitHub

Lua API Difficulty Version

๐Ÿš€ Quick Start Guide for file and folder operations with LuaDoTheWorld


๐Ÿ“‹ What You'll Learn

  • โœ… How to load and write files
  • โœ… How to copy and move files or folders (overwrite or merge)

๐Ÿ› ๏ธ Prerequisites

  • LuaDoTheWorld installed and required in your script

๐Ÿ“‚ Load a File

local dtw = require("luaDoTheWorld/luaDoTheWorld")
local content = dtw.load_file("tests/target/a.txt")
print(content)

๐Ÿ“ Write a File

local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.write_file("tests/target/b.txt", "text content")

๐Ÿ“‹ Copy Anything (Overwrite)

This will copy a file or folder, overwriting whatever is at the destination.

local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.copy_any_overwriting("tests/target/test_dir", "tests/target/a")

๐Ÿ”€ Copy Anything (Merge)

This will copy and merge folders if the destination is a folder.

local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.copy_any_merging("tests/target/test_dir", "tests/target/a")

๐Ÿšš Move Anything (Overwrite)

This will move a file or folder, removing the destination if it exists.

local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.move_any_overwriting("tests/target/test_dir", "tests/target/a")

๐Ÿ”„ Move Anything (Merge)

This will move and merge folders if the destination is a folder.

local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.move_any_merging("tests/target/test_dir", "tests/target/a")

๐Ÿ“š Quick Reference

FunctionWhat it doesExample
dtw.load_file(path)Load file contentdtw.load_file("a.txt")
dtw.write_file(path, data)Write content to filedtw.write_file("b.txt", "text")
dtw.copy_any_overwriting(src, dest)Copy and overwritedtw.copy_any_overwriting("dir", "a")
dtw.copy_any_merging(src, dest)Copy and mergedtw.copy_any_merging("dir", "a")
dtw.move_any_overwriting(src, dest)Move and overwritedtw.move_any_overwriting("dir", "a")
dtw.move_any_merging(src, dest)Move and mergedtw.move_any_merging("dir", "a")

๐Ÿ†˜ Need Help?

  • ๐Ÿ“– Check the main SDK documentation
  • ๐Ÿ” Look at other example scripts in the SDK
  • ๐Ÿ› Report issues on our GitHub repository

Footer