I've been working on a mod that produces the following resource maps. RustyPickaxe – Rustfanatic
The issue I have at the moment is I can't save the PNG/JPG files out because Oxide is blocking my access to System.IO.File, instead I'm piping the image data to my web server and saving it locally there.
In the interest of publishing this mod for others it'd be great to be able to save the image data to the oxide data directory on the Rust server. I've seen some plugins do it, particularly the RustIO plugin that dumps a map out.
Any suggestions here?
Saving PNG/JPG Files from Mod
Discussion in 'Rust Development' started by Wukey, Aug 28, 2015.
-
You might be able to get around this by using win32 api commands through p/invoke
See: Using Explicit PInvoke in C++ (DllImport Attribute) -
-
-
It wouldn't be possible from a plugin; you will need to create an extension if you wanted to do it locally.
-
-
Code:if (method.HasPInvokeInfo) { method.Attributes &= ~MethodAttributes.PInvokeImpl; var body = new MethodBody(method); body.Instructions.Add(Instruction.Create(OpCodes.Ldstr, "PInvoke access is restricted, you are not allowed to use PInvoke")); body.Instructions.Add(Instruction.Create(OpCodes.Newobj, security_exception)); body.Instructions.Add(Instruction.Create(OpCodes.Throw)); method.Body = body; }
-
Thanks, no need to sigh, the internet is so full of assumptions that taking decisions based on them is a sure way to get nowhere
-
Oh... I have an idea that would work. Save the image bytes to a config (with WriteObject) and then just create an offline parser that loads the JSON and saves the data to disk. For your needs it would work.
-
Wulf Community Admin
FYI: Rust:IO is not a plugin, it's an extension. Extensions are not sandboxed, so if you really needed to access something that isn't allowed, that would be the way to go. Keep in mind that most hosts will not allow unofficial extensions though due to the security concerns and lack of sandboxing of them.
-
-
Calytic Community Admin Community Mod
I suggest looking at the SignArtist plugin. You can save/load images locally using the built-in FileStorage class. As far as saving them on the filesystem as images, that is not possible without an Oxide extension. However, you could save the byte array in an oxide datafile, or alternatively rely solely on FileStorage to store/load your images. I haven't tested this with anything other than signs but I do use the byte arrays to upload images to a webserver in addition to storing them locally.