Skip to content

Latest commit

Β 

History

History
109 lines (71 loc) Β· 2.75 KB

File metadata and controls

109 lines (71 loc) Β· 2.75 KB

🧩 IO Guide

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

Function What it does Example
dtw.load_file(path) Load file content dtw.load_file("a.txt")
dtw.write_file(path, data) Write content to file dtw.write_file("b.txt", "text")
dtw.copy_any_overwriting(src, dest) Copy and overwrite dtw.copy_any_overwriting("dir", "a")
dtw.copy_any_merging(src, dest) Copy and merge dtw.copy_any_merging("dir", "a")
dtw.move_any_overwriting(src, dest) Move and overwrite dtw.move_any_overwriting("dir", "a")
dtw.move_any_merging(src, dest) Move and merge dtw.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