Advertisement
ASMProgrammer

Minecraft OpenComputers Mod Load file in to lua

Oct 31st, 2023 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.42 KB | None | 0 0
  1. local addr, invoke = computer.getBootAddress(), component.invoke
  2. local function loadfile(file)
  3.   local handle = assert(invoke(addr, "open", file))
  4.   local buffer = ""
  5.   repeat
  6.     local data = invoke(addr, "read", handle, math.maxinteger or math.huge)
  7.     buffer = buffer .. (data or "")
  8.   until not data
  9.   invoke(addr, "close", handle)
  10.   return load(buffer, "=" .. file, "bt", _G)
  11. end
  12. loadfile("<file>")(loadfile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement