blob: 0e4ccb7d51839f8894f050bc438129042407ffe4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-- TestLuaRocks.lua
-- This is a mockup plugin that does a quick test of LuaRocks capability in Cuberite
-- "Success" is when the plugin loads, downloads the forum webpage and displays the headers and length and then displays both libs as loaded.
-- "Failure" usually manifests as one of the "require" lines failing, although you have the luarock installed.
-- Note that the plugin deliberately never fully loads, so that it can be reloaded fast by pressing its Enable button in the webadmin's plugin list.
local log30 = require("30log");
local socket = require("socket");
local http = require("socket.http");
LOGINFO("Trying to download a webpage...");
local body, code, headers = http.request('http://forum.mc-server.org/index.php');
LOG("code: " .. tostring(code));
LOG("headers: ");
for k, v in pairs(headers or {}) do
LOG(" " .. k .. ": " .. v);
end
LOG("body length: " .. string.len(body));
function Initialize(a_Plugin)
if (socket == nil) then
LOG("LuaSocket not found");
else
LOG("LuaSocket loaded");
end
if (log30 == nil) then
LOG("30log not found");
else
LOG("30log loaded");
end
LOGINFO("Preventing plugin load so that it may be requested again from the webadmin.");
return false;
end
|