connected/init.lua

26 lines
686 B
Lua
Raw Normal View History

2016-09-30 00:34:33 -07:00
local http_api = minetest.request_http_api()
if not http_api then
print("ERROR: in minetest.conf, this mod must be in secure.http_mods!")
end
local node = minetest.register_node("connected:iotswitch", {
2016-09-30 00:34:33 -07:00
tiles = {"textures/tutorial_decowood.png"},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
on_rightclick = function (pos, node)
print("punch")
minetest.after(1, function()
2016-09-30 00:34:33 -07:00
http_api.fetch({
url = "http://localhost:8088/punch",
2016-09-30 00:34:33 -07:00
timeout = 1
},
function (res)
print(dump(res))
end)
end)
end,
on_construct = function(pos)
-- register with rest API to the server ?
print(dump(pos))
end
2016-09-30 00:34:33 -07:00
})