vengi-voxel / vengi

free and open source voxel art tools - editor, thumbnailer and format converter
http://vengi-voxel.github.io/vengi/
Other
1.05k stars 87 forks source link

ALL: lua plugin api #438

Closed mgerhardy closed 2 months ago

mgerhardy commented 2 months ago

it would be cool to get more script bindings for stuff like streams and http access to connect to external apis via lua scripts.

mgerhardy commented 2 months ago

11a1e379449c95e52c91953c75f3e7a7d254bfa2 added the g_http global for simple GET downloads. There are no headers possible yet, nor POST requests with bodies.

mgerhardy commented 2 months ago

http and stream functions are implemented now (and a few others)

an example to download an import a file from the web might look like this

local function basename(str)
    local name = string.gsub(str, "(.*/)(.*)", "%2")
    return name
end

function main(_, _, _)
    local url = "https://github.com/vengi-voxel/vengi/raw/9c101f32b84f949ed82f7545883e80a318760580/data/voxel/guybrush.vox"
    local filename = basename(url)
    local stream = g_http.get(url)
    g_import.scene(filename, stream)
end

with this you are able to connect to generating api - be it images or voxels. Find the details in the docs regarding the lua scripting.