Hi, wolfs is back!
This is probably the biggest expansion Lua has gotten in a long time. Originally removed for being too dangerous, this mod reimplements the input/output library into SRB2's Lua API. With this, you can now read, edit, or create files using Lua scripts! Of course, for sanity purposes, a lot of security restrictions had to be put in place. They are as follows:
I/O is pretty new, and is not documented on the SRB2 Wiki yet. For a reference on I/O functions in Lua and how they are used, check here.
The zip here includes the SDL2 build (srb2io.exe) and a DirectDraw build. (srb2iodd.exe) Linux guys, I'm sorry, but you're gonna have to compile your own binaries. I have no stable Linux testing environment aside from a VPS with a really specific compile setup.
About netgame compatibility:
The build here is compiled off of the latest public master branch of the SRB2 repo. The io branch itself is based on the next branch, but changing that requires copying a mere three files into any other repo. As it is compiled on master, it *should* be netgame compatible with 2.1.14, but I wouldn't rely on it much. If you are hosting with an I/O build, I strongly urge you not to use any functions that would affect other players. Use the functions locally and have them only apply to the server. Alternatively, you can avoid playing netgames with this build entirely and wait until I/O becomes a vanilla feature in 2.2. The choice is yours.
Please remember to report any and all bugs you find. I/O can be a rather volatile thing so it's important that any major system security issues are taken care of.
With that said, have fun, and please don't use the I/O library to be an asshole. :3
Source Code
LightDash Mirror
This is probably the biggest expansion Lua has gotten in a long time. Originally removed for being too dangerous, this mod reimplements the input/output library into SRB2's Lua API. With this, you can now read, edit, or create files using Lua scripts! Of course, for sanity purposes, a lot of security restrictions had to be put in place. They are as follows:
- .., :, and % cannot be used in path strings. Any attempt to do so will result in Lua throwing a warning.
- Path strings cannot start with / or \\. This, along with the changes above, was done to prevent users from leaving the SRB2 directory.
- All files are written into a new directory named luafiles by default. This was done for security and organization reasons.
- You can specify non-existent subdirectories in your path string and the game will automatically create them for you.
- io.popen() has been removed. This function would allow scripters to open programs with the Lua API. Naturally this is a terrible idea.
- File size has been limited to 1MB. If a file is over 1MB and you attempt to append it, it will not be modified. If a file is under 1MB and your change would bring it over, it is discarded. (contents erased if mode is "w", contents unmodified if mode is "a+")
- A whitelist has been included for specific filetypes. Any attempts to use different file types will result in Lua throwing a warning. Supported filetypes are .txt, .sav2, .cfg, .png, and .bmp.
I/O is pretty new, and is not documented on the SRB2 Wiki yet. For a reference on I/O functions in Lua and how they are used, check here.
The zip here includes the SDL2 build (srb2io.exe) and a DirectDraw build. (srb2iodd.exe) Linux guys, I'm sorry, but you're gonna have to compile your own binaries. I have no stable Linux testing environment aside from a VPS with a really specific compile setup.
About netgame compatibility:
The build here is compiled off of the latest public master branch of the SRB2 repo. The io branch itself is based on the next branch, but changing that requires copying a mere three files into any other repo. As it is compiled on master, it *should* be netgame compatible with 2.1.14, but I wouldn't rely on it much. If you are hosting with an I/O build, I strongly urge you not to use any functions that would affect other players. Use the functions locally and have them only apply to the server. Alternatively, you can avoid playing netgames with this build entirely and wait until I/O becomes a vanilla feature in 2.2. The choice is yours.
Please remember to report any and all bugs you find. I/O can be a rather volatile thing so it's important that any major system security issues are taken care of.
With that said, have fun, and please don't use the I/O library to be an asshole. :3
Source Code
LightDash Mirror
Attachments
Last edited: