plugins/xkcd2.lua

changeset 132
feafc98e8c78
parent 124
4530954f545a
equal deleted inserted replaced
116:0735c0b39d4a 132:feafc98e8c78
15 local url = current_url; 15 local url = current_url;
16 local q = command.param; 16 local q = command.param;
17 local strip; 17 local strip;
18 18
19 if q then 19 if q then
20 local t, num = q:match("^([#\"]?)(%d+)\"?$"); 20 local t, num = q:match("^([#\"]?)(%-?%d+)\"?$");
21 if t ~= '"' then 21 if t ~= '"' then
22 num = tonumber(num); 22 num = tonumber(num);
23 if num and num < 0 then 23 if num and num < 0 then
24 num = #strip + num; 24 num = table.maxn(strips) + num;
25 end 25 end
26 end 26 end
27 strip = strips[num or q:lower()]; 27 strip = strips[num or q:lower()];
28 if strip == "" or strip == 404 then 28 if strip == "" or strip == 404 then
29 strip = nil 29 strip = nil
170 170
171 strips = {}; 171 strips = {};
172 return "List of strips emptied"; 172 return "List of strips emptied";
173 end); 173 end);
174 174
175 do_load();
175 end 176 end

mercurial