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
|
|
|
|
|
2016-10-06 04:59:46 -07:00
|
|
|
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")
|
2016-10-01 14:39:35 -07:00
|
|
|
minetest.after(1, function()
|
2016-09-30 00:34:33 -07:00
|
|
|
http_api.fetch({
|
2016-10-01 14:39:35 -07:00
|
|
|
url = "http://localhost:8088/punch",
|
2016-09-30 00:34:33 -07:00
|
|
|
timeout = 1
|
|
|
|
},
|
|
|
|
function (res)
|
|
|
|
print(dump(res))
|
|
|
|
end)
|
|
|
|
end)
|
2016-10-06 04:59:46 -07:00
|
|
|
end,
|
|
|
|
on_construct = function(pos)
|
|
|
|
-- register with rest API to the server ?
|
|
|
|
print(dump(pos))
|
|
|
|
end
|
2016-09-30 00:34:33 -07:00
|
|
|
})
|