Skip to content

`loadfile` in Lua

Golden requested to merge Golden/SRB2:loadfile into next

A loadfile implementation for SRB2.

Lua scripters:

  • loadfile exists now, and it's basically dofile, but instead of calling the file immediately, the file is returned as a function for you to do stuff with, like sending it arguments and doing setfenv shenanigans.

C people:

  • LUA_DoLump replaces the old LUA_LoadLump; LUA_LoadLump does loadfile stuff now.
  • LUA_DoLump (and by extension dofile) is now implemented internally as the equivalent of loadfile("filename.lua")()

Here's a cool PK3 that self-tests itself. It will check for basically every case I've thought of so far.
loadfile.pk3

Edited by Golden

Merge request reports

Loading