Skip to content
Snippets Groups Projects
init.lua 804 B
Newer Older
Tuxilio's avatar
Tuxilio committed
-- SPDX-FileCopyrightText: 2024 Tuxilio <mail@tuxil.io>
--
-- SPDX-License-Identifier: GPL-3.0-or-later

local HTTPApiTable = core.request_http_api()
local data = {
    url = "http://server.de",
    token = "",
}

change_color = function(led_id)
    local resquest = {
        url = data.url,
        method = 'POST',
        timeout = 15,
        extra_headers = {
            "Authorization: Bearer "..data.token,
        }
    }
    HTTPApiTable.fetch(request, function (response)
        print(dump(request))
        if response.code ~= 200 then
            return false
        else
            return true
        end
    end
end

for i=1, 10, 1 do
    core.register_node("ledtree:led"..i, {
        description = "LED"..i,
        --tiles = "",
        on_rightclick = change_color(i),
    })
end