Closed danielniccoli closed 4 years ago
Not currently. I can probably add a way to do that if you can describe what exactly you want. For example, do you want to supply image dimensions? Should the image be saved locally or uploaded to an image host? Do you want a commandline option or config file option for the previous question? Etc etc
Also, it would be nice if you could describe your general use case(s). For example, the web API that is already available might also do the job, depending on the use case.
My use case is this: I'd like to render a blueprint string using FSBR from within my python. Using your web API would add unnecessary overhead, both to the python app and the system configuration. Having a jar file would make it much simpler. I could call that from my python app as well as from a cron job.
Talking about options is a bit difficult for me. I don't know what options FSBR offers. I just describe a few, that I would find handy.
(Visual reference)
--config "/opt/fsbr/settings"
.--blueprint-string <string>
--label=<yes|no>
--grid=<yes|no>
--grid-lines=<yes|no>
--grid-index=<yes|no>
--resources=<yes|no>
--raw-resources=<yes|no>
--show-info=<yes|no>
--output=<file>
The reason for preferring the Web API over running command arguments to a jar, is because FBSR pre-loads a lot of information related to image assets and running the lua interpreter on the factorio data. If you were to try and run FBSR every time you need an image rendered, you would have a large overhead of loading the factorio data every time.
I see. Makes sense.
So back to topic, I now know there is a web service that I can start. How do I actually do that?
(I found an issue with one of the repositories while trying to test this)
The Web API only works on Java 8
You can modify the config.json to be only a Web API:
{
"webapi": {
"port": 8081,
"bind": "0.0.0.0",
"use-local-storage": true,
"local-storage": "C:\\FBSR\\Images"
},
"factorio": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Factorio"
}
Set local-storage
to a folder your python script can access. FBSR will use this folder to store completed image renders.
Command the Web API by sending a POST to /blueprint containing a JSON object:
POST http://localhost:8081/blueprint
Content-Type: application/json
{
"blueprint": "https://pastebin.com/REkHLQTj (or any blueprint string)",
"show-info-panels": true,
"max-width": 10000,
"max-height": 10000
}
The Web API will reply with a JSON object:
{
"info": ["(Modded features are shown as question marks)"],
"images": [
{"link": "Blueprint1591052237564.png"},
{"link": "Blueprint1591052237699.png"},
{"link": "Blueprint1591052237812.png"},
{"link": "Blueprint1591052237964.png"},
{"link": "Blueprint1591052238095.png"},
{"link": "Blueprint1591052238205.png"},
{"link": "Blueprint1591052238329.png"},
{"link": "Blueprint1591052238464.png"},
{"link": "Blueprint1591052238570.png"},
{"link": "Blueprint1591052238684.png"},
{"link": "Blueprint1591052238778.png"},
{"link": "Blueprint1591052238843.png"},
{"link": "Blueprint1591052239006.png"},
{"link": "Blueprint1591052239108.png"},
{"link": "Blueprint1591052240965.png"}
]
}
show-info-panels
, max-width
, and max-height
are optional.
Right now, there is no guide to setting up, running, or building a jar.
Since an extensive guide is beyond the scope of this issue, I'll only outline the general process here. If you would like some more help, find me on discord (Demod#0001) and I'll try to walk through the process.
java -Xmx4g -jar <jar file>.jar
. The program java
should be installed on the PATH when Java JDK 8 was installed, but if not, you can directly call java.exe in the bin folder of the Java 8 JDK install location.Whew.
I hope I did not forget anything when writing down these instructions, I'll edit this comment if I find something else to add!
Thanks, that worked. Haven't run the jar yet, but I could build and package it. If it's not too much to ask, maybe when you do your next version, could you upload the jar as a release package in github? That' be great.
Can I use this to render a blueprint string locally, by passing the blueprint string in the command line?
How would I do that?