Openarl / PathOfBuilding

Offline build planner for Path of Exile.
MIT License
2.15k stars 1.04k forks source link

How can I import a build and get its statistics in lua? #1835

Open FrancoisMentec opened 4 years ago

FrancoisMentec commented 4 years ago

I'm trying to run pob in a browser using fengari. I don't need all the functionalities, all I need is to be able to get the statistics (dps, life, ...) from a code generated by pob and calculate the impact an item would have on the build.

I've been looking into Classes/ImportTab.lua how I could import a build and found two lines: local xmlText = Inflate(common.base64.decode(buf:gsub("-","+"):gsub("_","/")))
and
self.build:Init(false, "Imported build", self.importCodeXML).
I suppose buf is the code, but Inflate that is found in HeadlessWrapper.lua return an empty string:

function Inflate(data)
    -- TODO: And this
    return ""
end

Also, I'm not sure what is self.build. it is passed as a parameter to ImportTabClass, but I couldn't find any instantiation of this class. I suppose it's buildMode that is defined in Modules/Build.lua.
So far I failed to load a build.
Is there someone that could provide me with a minimalistic case of how to load a build from a code generated by pob and get its statistics and the impact of an item.
Example:

build = Build(code_generated_by_pob)
build.setSpell('Barrage')
print(build.stats)
print(build.stats['dps'])
newItem = Item.createCustom(code_of_the_item)
print(build.getImpact(newItem))

I don't need any kind of user interface or way to save the build, items or modifications.
Any help would be highly appreciated.

ppoelzl commented 4 years ago

Inflate and Deflate are decompression/compression routines for files compressed with the Deflate algorithm, loaded from lzip.dll in the C environment the Lua runtime is embedded in. As the comments indicate, if you want to run PoB headless in a different environment, you will need to implement this functionality yourself.

FrancoisMentec commented 4 years ago

So I have do decompress/Inflate a code generated by pob so it can be loaded? Any idea how I could do the rest (like instantiating the build from a generated code, getting the stats, ...)?

ppoelzl commented 4 years ago

You can take a look at how they did it here. Also, please remove this. It's impossible for others to "support" you without breaking paragraph 7b. of Path of Exile's ToS.