repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
Alireza5928/pv
extra.lua
8
1180
function send_fwrd(chat_id, from_id, msg_id) local urla = send_api.."/forwardMessage?chat_id="..chat_id.."&from_chat_id="..from_id.."&message_id="..msg_id return send_req(urla) end function send_phone(chat_id, number, name) local urla = send_api.."/sendContact?chat_id="..chat_id.."&phone_number="..url.escape(tonumber(number)).."&first_name="..url.escape(name) return send_req(urla) end function send_sms(number, text) local base = "curl 'http://umbrella.shayan-soft.ir/sms/send.php?number="..url.escape(tonumber(number)).."&text="..url.escape(text).."'" local result = io.popen(base):read('*all') return result end function send_inline(chat_id, text, keyboard) local response = {} response.inline_keyboard = keyboard local responseString = json.encode(response) local sended = send_api.."/sendMessage?chat_id="..chat_id.."&text="..url.escape(text).."&parse_mode=Markdown&disable_web_page_preview=true&reply_markup="..url.escape(responseString) return send_req(sended) end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end
apache-2.0
yang2507366/Savanna
Savanna.bundle/UIKit/UIActionSheet.lua
1
4623
require "UIView" require "AppContext" require "CommonUtils" require "StringUtils" class(UIActionSheet, UIView); function UIActionSheet:create(title, cancelButtonTitle, destructiveButtonTitle, ...--[[button titles]]) if not cancelButtonTitle then cancelButtonTitle = ""; end if not destructiveButtonTitle then destructiveButtonTitle = ""; end self = self:get(runtime::invokeClassMethod("LIActionSheet", "create:title:", AppContext.current(), title)); for i=1,arg.n do self:addButtonWithTitle(arg[i]); end local count = arg.n; if StringUtils.length(destructiveButtonTitle) ~= 0 then self:addButtonWithTitle(destructiveButtonTitle); self:setDestructiveButtonIndex(count); count = count + 1; end if StringUtils.length(cancelButtonTitle) ~= 0 then self:addButtonWithTitle(cancelButtonTitle); self:setCancelButtonIndex(count); end return self; end function UIActionSheet:get(asId) local as = super:get(asId); runtime::invokeMethod(asId, "setClickedButtonAtIndex:", "UIActionSheet_clickedButtonAtIndex"); runtime::invokeMethod(asId, "setActionSheetCancel:", "UIActionSheet_cancel"); runtime::invokeMethod(asId, "setDidDismissWithButtonIndex:", "UIActionSheet_didDismissWithButtonIndex"); runtime::invokeMethod(asId, "setWillDismissWithButtonIndex:", "UIActionSheet_willDismissWithButtonIndex"); UIActionSheetEventProxyTable[asId] = as; return as; end function UIActionSheet:title() return runtime::invokeMethod(self:id(), "title"); end function UIActionSheet:setTitle(title) runtime::invokeMethod(self:id(), "setTitle:", title); end function UIActionSheet:setDestructiveButtonIndex(buttonIndex) runtime::invokeMethod(self:id(), "setDestructiveButtonIndex:", buttonIndex); end function UIActionSheet:destructiveButtonIndex() return tonumber(runtime::invokeMethod(self:id(), "destructiveButtonIndex")); end function UIActionSheet:cancelButtonIndex() return tonumber(runtime::invokeMethod(self:id(), "cancelButtonIndex")); end function UIActionSheet:setCancelButtonIndex(buttonIndex) runtime::invokeMethod(self:id(), "setCancelButtonIndex:", buttonIndex); end function UIActionSheet:showInView(view) runtime::invokeMethod(self:id(), "showInView:", view:id()); end function UIActionSheet:showFromToolbar(toolbar) runtime::invokeMethod(self:id(), "showFromToolbar:", toolbar:id()); end function UIActionSheet:showFromTabBar(tabBar) runtime::invokeMethod(self:id(), "showFromTabBar:", tabBar:id()); end function UIActionSheet:showFromRect(x, y, width, height, view, animated--[[option]]) runtime::invokeMethod(self:id(), "showFromRect:inView:animated:", toCStruct(x, y, width, height), view:id(), toObjCBool(animated)); end function UIActionSheet:showFromBarButtonItem(barButtonItem) runtime::invokeMethod(self:id(), "showFromBarButtonItem:animated:", barButtonItem:id(), toObjCBool(animated)); end function UIActionSheet:addButtonWithTitle(title) return tonumber(runtime::invokeMethod(self:id(), "addButtonWithTitle:", title)); end function UIActionSheet:buttonTitleAtIndex(index) return runtime::invokeMethod(self:id(), "buttonTitleAtIndex:", index); end function UIActionSheet:dismissWithClickedButtonIndex(buttonIndex, animated) runtime::invokeMethod(self:id(), "dismissWithClickedButtonIndex:animated:", buttonIndex, toObjCBool(animated)); end function UIActionSheet:dealloc() UIActionSheetEventProxyTable[self:id()] = nil; super:dealloc(); end function UIActionSheet:clickedButtonAtIndex(index)--[[event]] end function UIActionSheet:didCancel()--[[event]] end function UIActionSheet:willDismissWithButtonIndex(buttonIndex)--[[event]] end function UIActionSheet:didDismissWithButtonIndex(buttonIndex)--[[event]] end UIActionSheetEventProxyTable = {}; function UIActionSheet_clickedButtonAtIndex(asId, index) local as = UIActionSheetEventProxyTable[asId]; if as then as:clickedButtonAtIndex(tonumber(index)); end end function UIActionSheet_cancel(asId) local as = UIActionSheetEventProxyTable[asId]; if as then as:didCancel(); end end function UIActionSheet_willDismissWithButtonIndex(asId, index) local as = UIActionSheetEventProxyTable[asId]; if as then as:willDismissWithButtonIndex(tonumber(index)); end end function UIActionSheet_didDismissWithButtonIndex(asId, index) local as = UIActionSheetEventProxyTable[asId]; if as then as:didDismissWithButtonIndex(tonumber(index)); end end
apache-2.0
TelegramDev/TeleMoon
bot/utils.lua
473
24167
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end --Check if this chat is realm or not function is_realm(msg) local var = false local realms = 'realms' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(realms)] then if data[tostring(realms)][tostring(msg.to.id)] then var = true end return var end end --Check if this chat is a group or not function is_group(msg) local var = false local groups = 'groups' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(groups)] then if data[tostring(groups)][tostring(msg.to.id)] then var = true end return var end end function savelog(group, logtxt) local text = (os.date("[ %c ]=> "..logtxt.."\n \n")) local file = io.open("./groups/logs/"..group.."log.txt", "a") file:write(text) file:close() end function user_print_name(user) if user.print_name then return user.print_name end local text = '' if user.first_name then text = user.last_name..' ' end if user.lastname then text = text..user.last_name end return text end --Check if user is the owner of that group or not function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_owner2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is admin or not function is_admin(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_admin2(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_momod(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['moderators'] then if data[tostring(msg.to.id)]['moderators'][tostring(user)] then var = true end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_momod2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(group_id)] then if data[tostring(group_id)]['moderators'] then if data[tostring(group_id)]['moderators'][tostring(usert)] then var = true end end end if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == usert then var = true end end return var end -- Returns the name of the sender function kick_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_owner2(user_id, chat_id) then -- Ignore admins return end local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end -- Ban function ban_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'banned:'..chat_id redis:sadd(hash, user_id) -- Kick from chat kick_user(user_id, chat_id) end -- Global ban function banall_user(user_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'gbanned' redis:sadd(hash, user_id) end -- Global unban function unbanall_user(user_id) --Save on redis local hash = 'gbanned' redis:srem(hash, user_id) end -- Check if user_id is banned in chat_id or not function is_banned(user_id, chat_id) --Save on redis local hash = 'banned:'..chat_id local banned = redis:sismember(hash, user_id) return banned or false end -- Check if user_id is globally banned or not function is_gbanned(user_id) --Save on redis local hash = 'gbanned' local banned = redis:sismember(hash, user_id) return banned or false end -- Returns chat_id ban list function ban_list(chat_id) local hash = 'banned:'..chat_id local list = redis:smembers(hash) local text = "Ban list !\n\n" for k,v in pairs(list) do local user_info = redis:hgetall('user:'..v) -- vardump(user_info) if user_info then if user_info.username then user = '@'..user_info.username elseif user_info.print_name and not user_info.username then user = string.gsub(user_info.print_name, "_", " ") else user = '' end text = text..k.." - "..user.." ["..v.."]\n" end end return text end -- Returns globally ban list function banall_list() local hash = 'gbanned' local list = redis:smembers(hash) local text = "global bans !\n\n" for k,v in pairs(list) do local user_info = redis:hgetall('user:'..v) -- vardump(user_info) if user_info then if user_info.username then user = '@'..user_info.username elseif user_info.print_name and not user_info.username then user = string.gsub(user_info.print_name, "_", " ") else user = '' end text = text..k.." - "..user.." ["..v.."]\n" end end return text end -- /id by reply function get_message_callback_id(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id send_large_msg(chat, result.from.id) else return 'Use This in Your Groups' end end -- kick by reply for mods and owner function Kick_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end -- Kick by reply for admins function Kick_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_admin2(result.from.id) then -- Ignore admins return end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end --Ban by reply for admins function ban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Ban by reply for admins function ban_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_admin2(result.from.id) then -- Ignore admins return end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Unban by reply function unban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't unban myself" end send_large_msg(chat, "User "..result.from.id.." Unbanned") -- Save on redis local hash = 'banned:'..result.to.id redis:srem(hash, result.from.id) else return 'Use This in Your Groups' end end function banall_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't banall myself" end if is_admin2(result.from.id) then -- Ignore admins return end local name = user_print_name(result.from) banall_user(result.from.id) chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered") else return 'Use This in Your Groups' end end
gpl-2.0
danteinforno/wesnoth
host.lua
26
2733
-- host.lua -- -- Try to host a game called "Test" local function plugin() local function log(text) std_print("host: " .. text) end local counter = 0 local events, context, info local helper = wesnoth.require("lua/helper.lua") local function idle_text(text) counter = counter + 1 if counter >= 100 then counter = 0 log("idling " .. text) end end log("hello world") repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for titlescreen or lobby") until info.name == "titlescreen" or info.name == "Multiplayer Lobby" while info.name == "titlescreen" do context.play_multiplayer({}) log("playing multiplayer...") events, context, info = coroutine.yield() end repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for lobby") until info.name == "Multiplayer Lobby" context.chat({message = "hosting"}) log("creating a game") context.create({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for create") until info.name == "Multiplayer Create" context.select_type({type = "scenario"}) local s = info.find_level({id = "test1"}) if s.index < 0 then log(" error: Could not find scenario with id=test1") end context.select_level({index = s.index}) events, context, info = coroutine.yield() log("configuring a game") context.create({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for configure") until info.name == "Multiplayer Configure" context.set_name({name = "Test"}) log("hosting a game") context.launch({}) ready = nil repeat events, context, info = coroutine.yield() for i,v in ipairs(events) do if v[1] == "chat" then std_print(events[i][2]) if v[2].message == "ready" then ready = true end end end idle_text("in " .. info.name .. " waiting for ready in chat") until ready log("starting game...") context.chat({message = "starting"}) context.launch({}) repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for game") until info.name == "Game" log("got to a game context...") repeat events, context, info = coroutine.yield() idle_text("in " .. info.name .. " waiting for not game") until info.name ~= "Game" log("left a game context...") repeat context.quit({}) log("quitting a " .. info.name .. " context...") events, context, info = coroutine.yield() until info.name == "titlescreen" context.exit({code = 0}) coroutine.yield() end return plugin
gpl-2.0
kmfreeminer/km-freeminer-mods
mods/jabber/lib/verse/client.lua
2
6104
local verse = require "verse"; local stream = verse.stream_mt; local jid_split = require "util.jid".split; local adns = require "net.adns"; local lxp = require "lxp"; local st = require "util.stanza"; -- Shortcuts to save having to load util.stanza verse.message, verse.presence, verse.iq, verse.stanza, verse.reply, verse.error_reply = st.message, st.presence, st.iq, st.stanza, st.reply, st.error_reply; local new_xmpp_stream = require "util.xmppstream".new; local xmlns_stream = "http://etherx.jabber.org/streams"; local function compare_srv_priorities(a,b) return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); end local stream_callbacks = { stream_ns = xmlns_stream, stream_tag = "stream", default_ns = "jabber:client" }; function stream_callbacks.streamopened(stream, attr) stream.stream_id = attr.id; if not stream:event("opened", attr) then stream.notopen = nil; end return true; end function stream_callbacks.streamclosed(stream) stream.notopen = true; if not stream.closed then stream:send("</stream:stream>"); stream.closed = true; end stream:event("closed"); return stream:close("stream closed") end function stream_callbacks.handlestanza(stream, stanza) if stanza.attr.xmlns == xmlns_stream then return stream:event("stream-"..stanza.name, stanza); elseif stanza.attr.xmlns then return stream:event("stream/"..stanza.attr.xmlns, stanza); end return stream:event("stanza", stanza); end function stream_callbacks.error(stream, e, stanza) if stream:event(e, stanza) == nil then if stanza then local err = stanza:get_child(nil, "urn:ietf:params:xml:ns:xmpp-streams"); local text = stanza:get_child_text("text", "urn:ietf:params:xml:ns:xmpp-streams"); error(err.name..(text and ": "..text or "")); else error(stanza and stanza.name or e or "unknown-error"); end end end function stream:reset() if self.stream then self.stream:reset(); else self.stream = new_xmpp_stream(self, stream_callbacks); end self.notopen = true; return true; end function stream:connect_client(jid, pass) self.jid, self.password = jid, pass; self.username, self.host, self.resource = jid_split(jid); -- Required XMPP features self:add_plugin("tls"); self:add_plugin("sasl"); self:add_plugin("bind"); self:add_plugin("session"); function self.data(conn, data) local ok, err = self.stream:feed(data); if ok then return; end self:debug("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " ")); self:close("xml-not-well-formed"); end self:hook("connected", function () self:reopen(); end); self:hook("incoming-raw", function (data) return self.data(self.conn, data); end); self.curr_id = 0; self.tracked_iqs = {}; self:hook("stanza", function (stanza) local id, type = stanza.attr.id, stanza.attr.type; if id and stanza.name == "iq" and (type == "result" or type == "error") and self.tracked_iqs[id] then self.tracked_iqs[id](stanza); self.tracked_iqs[id] = nil; return true; end end); self:hook("stanza", function (stanza) local ret; if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; if xmlns then ret = self:event("iq/"..xmlns, stanza); if not ret then ret = self:event("iq", stanza); end end if ret == nil then self:send(verse.error_reply(stanza, "cancel", "service-unavailable")); return true; end else ret = self:event(stanza.name, stanza); end end return ret; end, -1); self:hook("outgoing", function (data) if data.name then self:event("stanza-out", data); end end); self:hook("stanza-out", function (stanza) if not stanza.attr.xmlns then self:event(stanza.name.."-out", stanza); end end); local function stream_ready() self:event("ready"); end self:hook("session-success", stream_ready, -1) self:hook("bind-success", stream_ready, -1); local _base_close = self.close; function self:close(reason) self.close = _base_close; if not self.closed then self:send("</stream:stream>"); self.closed = true; else return self:close(reason); end end local function start_connect() -- Initialise connection self:connect(self.connect_host or self.host, self.connect_port or 5222); end if not (self.connect_host or self.connect_port) then -- Look up SRV records adns.lookup(function (answer) if answer then local srv_hosts = {}; self.srv_hosts = srv_hosts; for _, record in ipairs(answer) do table.insert(srv_hosts, record.srv); end table.sort(srv_hosts, compare_srv_priorities); local srv_choice = srv_hosts[1]; self.srv_choice = 1; if srv_choice then self.connect_host, self.connect_port = srv_choice.target, srv_choice.port; self:debug("Best record found, will connect to %s:%d", self.connect_host or self.host, self.connect_port or 5222); end self:hook("disconnected", function () if self.srv_hosts and self.srv_choice < #self.srv_hosts then self.srv_choice = self.srv_choice + 1; local srv_choice = srv_hosts[self.srv_choice]; self.connect_host, self.connect_port = srv_choice.target, srv_choice.port; start_connect(); return true; end end, 1000); self:hook("connected", function () self.srv_hosts = nil; end, 1000); end start_connect(); end, "_xmpp-client._tcp."..(self.host)..".", "SRV"); else start_connect(); end end function stream:reopen() self:reset(); self:send(st.stanza("stream:stream", { to = self.host, ["xmlns:stream"]='http://etherx.jabber.org/streams', xmlns = "jabber:client", version = "1.0" }):top_tag()); end function stream:send_iq(iq, callback) local id = self:new_id(); self.tracked_iqs[id] = callback; iq.attr.id = id; self:send(iq); end function stream:new_id() self.curr_id = self.curr_id + 1; return tostring(self.curr_id); end
gpl-3.0
litnimax/luci
applications/luci-p910nd/luasrc/model/cbi/p910nd.lua
74
1512
--[[ LuCI p910nd (c) 2008 Yanira <forum-2008@email.de> (c) 2012 Jo-Philipp Wich <jow@openwrt.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- local uci = luci.model.uci.cursor_state() local net = require "luci.model.network" local m, s, p, b m = Map("p910nd", translate("p910nd - Printer server"), translatef("First you have to install the packages to get support for USB (kmod-usb-printer) or parallel port (kmod-lp).")) net = net.init(m.uci) s = m:section(TypedSection, "p910nd", translate("Settings")) s.addremove = true s.anonymous = true s:option(Flag, "enabled", translate("enable")) s:option(Value, "device", translate("Device")).rmempty = true b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on.")) b.template = "cbi/network_netlist" b.nocreate = true b.unspecified = true function b.cfgvalue(...) local v = Value.cfgvalue(...) if v then return (net:get_status_by_address(v)) end end function b.write(self, section, value) local n = net:get_network(value) if n and n:ipaddr() then Value.write(self, section, n:ipaddr()) end end p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port.")) p.rmempty = true for i=0,9 do p:value(i, 9100+i) end s:option(Flag, "bidirectional", translate("Bidirectional mode")) return m
apache-2.0
gajop/Zero-K
units/empmissile.lua
2
3504
unitDef = { unitname = [[empmissile]], name = [[Shockley]], description = [[EMP missile]], buildCostEnergy = 600, buildCostMetal = 600, builder = false, buildPic = [[empmissile.png]], buildTime = 600, canAttack = true, category = [[SINK UNARMED]], collisionVolumeOffsets = [[0 15 0]], collisionVolumeScales = [[20 50 20]], collisionVolumeTest = 1, collisionVolumeType = [[CylY]], customParams = { description_de = [[EMP Rakete]], description_pl = [[Rakieta EMP]], helptext = [[The Shockley disables units in a small area for up to 45 seconds.]], helptext_de = [[Der Shockley paralysiert Einheiten in seiner kleinen Reichweite für bis zu 45 Sekunden.]], helptext_pl = [[Jednorazowa rakieta dalekiego zasiegu, ktora paralizuje trafione jednostki do 45 sekund.]], mobilebuilding = [[1]], }, explodeAs = [[EMP_WEAPON]], footprintX = 1, footprintZ = 1, iconType = [[cruisemissilesmall]], idleAutoHeal = 5, idleTime = 1800, maxDamage = 1000, maxSlope = 18, minCloakDistance = 150, objectName = [[wep_empmissile.s3o]], script = [[cruisemissile.lua]], seismicSignature = 4, selfDestructAs = [[EMP_WEAPON]], sfxtypes = { explosiongenerators = { [[custom:RAIDMUZZLE]] }, }, sightDistance = 0, useBuildingGroundDecal = false, yardMap = [[o]], weapons = { { def = [[EMP_WEAPON]], badTargetCategory = [[SWIM LAND SHIP HOVER]], onlyTargetCategory = [[SWIM LAND SINK TURRET FLOAT SHIP HOVER FIXEDWING GUNSHIP SUB]], }, }, weaponDefs = { EMP_WEAPON = { name = [[EMP Missile]], areaOfEffect = 280, avoidFriendly = false, cegTag = [[bigemptrail]], collideFriendly = false, craterBoost = 0, craterMult = 0, customparams = { stats_hide_dps = 1, -- one use stats_hide_reload = 1, light_color = [[1.35 1.35 0.36]], light_radius = 450, }, damage = { default = 30003.1, }, edgeEffectiveness = 1, explosionGenerator = [[custom:EMPMISSILE_EXPLOSION]], fireStarter = 0, flightTime = 20, impulseBoost = 0, impulseFactor = 0, interceptedByShieldType = 1, model = [[wep_empmissile.s3o]], paralyzer = true, paralyzeTime = 45, range = 3500, reloadtime = 3, smokeTrail = false, soundHit = [[weapon/missile/emp_missile_hit]], soundStart = [[weapon/missile/tacnuke_launch]], tolerance = 4000, tracks = false, turnrate = 12000, weaponAcceleration = 180, weaponTimer = 5, weaponType = [[StarburstLauncher]], weaponVelocity = 1200, }, }, featureDefs = { }, } return lowerkeys({ empmissile = unitDef })
gpl-2.0
CodeAnxiety/premake-core
tests/actions/vstudio/vc2010/test_vectorextensions.lua
5
2057
--- -- tests/actions/vstudio/vc2010/test_vectorextensions.lua -- Validate handling of vectorextensions() in VS 2010 C/C++ projects. -- -- Created 26 Mar 2015 by Jason Perkins -- Copyright (c) 2015 Jason Perkins and the Premake project --- local suite = test.declare("vs2010_vc_vectorextensions") local m = premake.vstudio.vc2010 local wks, prj function suite.setup() premake.action.set("vs2010") wks, prj = test.createWorkspace() end local function prepare() local cfg = test.getconfig(prj, "Debug") m.enableEnhancedInstructionSet(cfg) end function suite.instructionSet_onNotSet() test.isemptycapture() end function suite.instructionSet_onIA32_onVS2010() vectorextensions "IA32" prepare() test.isemptycapture() end function suite.instructionSet_onIA32() premake.action.set("vs2012") vectorextensions "IA32" prepare() test.capture [[ <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> ]] end function suite.instructionSet_onSSE() vectorextensions "SSE" prepare() test.capture [[ <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet> ]] end function suite.instructionSet_onSSE2() vectorextensions "SSE2" prepare() test.capture [[ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> ]] end function suite.instructionSet_onAVX() premake.action.set("vs2013") vectorextensions "AVX" prepare() test.capture [[ <EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet> ]] end function suite.instructionSet_onAVX_onVS2010() vectorextensions "AVX" prepare() test.isemptycapture() end function suite.instructionSet_onAVX2() premake.action.set("vs2013") vectorextensions "AVX2" prepare() test.capture [[ <EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet> ]] end function suite.instructionSet_onAVX2_onVS2012() premake.action.set("vs2012") vectorextensions "AVX2" prepare() test.isemptycapture() end
bsd-3-clause
gajop/Zero-K
scripts/armbrtha.lua
11
1839
local ground = piece 'ground' local base = piece 'base' local flare = piece 'flare' local muzzle = piece 'muzzle' local turret = piece 'turret' local barrel = piece 'barrel' local barrel_back = piece 'barrel_back' local sleeve = piece 'sleeve' include "constants.lua" include "pieceControl.lua" local spGetUnitIsStunned = Spring.GetUnitIsStunned -- Signal definitions local SIG_AIM = 2 local smokePiece = {base, turret, ground} local function DisableCheck() while true do if select(1, spGetUnitIsStunned(unitID)) then if StopTurn(sleeve, x_axis) then Signal(SIG_AIM) end if StopTurn(turret, y_axis) then Signal(SIG_AIM) end end Sleep(500) end end function script.Create() Hide(flare) Hide(muzzle) Hide(barrel_back) StartThread(SmokeUnit, smokePiece) StartThread(DisableCheck) end function script.AimWeapon(num, heading, pitch) Signal(SIG_AIM) SetSignalMask(SIG_AIM) Turn(turret, y_axis, heading, rad(5)) Turn(sleeve, x_axis, -pitch, rad(2.5)) WaitForTurn(turret, y_axis) WaitForTurn(sleeve, x_axis) return true end function script.FireWeapon(num) EmitSfx(ground, UNIT_SFX1) Move(barrel, z_axis, -24, 500) EmitSfx(barrel_back, UNIT_SFX2) EmitSfx(muzzle, UNIT_SFX3) WaitForMove(barrel, z_axis) Move(barrel, z_axis, 0, 6) end function script.QueryWeapon(num) return flare end function script.AimFromWeapon(num) return sleeve end function script.Killed(recentDamage, maxHealth) local severity = recentDamage / maxHealth if severity <= 0.25 then return 1 elseif severity <= 0.50 then Explode(sleeve, sfxShatter) Explode(turret, sfxShatter) return 1 else Explode(base, sfxShatter + sfxFall + sfxSmoke + sfxFire + sfxExplodeOnHit) Explode(sleeve, sfxShatter + sfxExplodeOnHit) Explode(turret, sfxFall + sfxSmoke + sfxFire + sfxExplodeOnHit) return 2 end end
gpl-2.0
punisherbot/botpunisher
plugins/ingroup.lua
202
31524
do local function check_member(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'You have been promoted as the owner.') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member,{receiver=receiver, data=data, msg = msg}) end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end local function show_group_settingsmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection return text end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection is already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection has been enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection is already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection has been disabled' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not data[tostring(msg.to.id)] then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n'..rules return rules end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been promoted.') end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been demoted.') end local function username_id(cb_extra, success, result) local mod_cmd = cb_extra.mod_cmd local receiver = cb_extra.receiver local member = cb_extra.member local text = 'No user @'..member..' in this group.' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end end send_large_msg(receiver, text) end local function modlist(msg) local data = load_data(_config.moderation.data) if not data[tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - @'..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name if success == -1 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end for k,v in pairs(result.members) do kick_user(v.id, result.id) end end local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if matches[1] == 'add' then print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'rem' then print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 then return automodadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local receiver = 'user#id'..msg.action.user.id local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return false end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id) send_large_msg(receiver, rules) end if matches[1] == 'chat_del_user' then if not msg.service then return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'promote' and matches[2] then if not is_owner(msg) then return "Only owner can promote" end local member = string.gsub(matches[2], "@", "") local mod_cmd = 'promote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end if matches[1] == 'demote' and matches[2] then if not is_owner(msg) then return "Only owner can demote" end if string.gsub(matches[2], "@", "") == msg.from.username then return "You can't demote yourself" end local member = string.gsub(matches[2], "@", "") local mod_cmd = 'demote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end end if matches[1] == 'settings' then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, data, target) end if matches[1] == 'newlink' then if not is_momod(msg) then return "For moderators only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'link' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "Group link:\n"..group_link end if matches[1] == 'setowner' then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = matches[2].." added as owner" return text end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "Group owner is ["..group_owner..']' end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." added as owner" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For moderators only!" end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Group flood has been set to '..matches[2] end if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return "Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if matches[1] == 'help' then if not is_momod(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end end end return { patterns = { "^[!/](add)$", "^[!/](rem)$", "^[!/](rules)$", "^[!/](about)$", "^[!/](setname) (.*)$", "^[!/](setphoto)$", "^[!/](promote) (.*)$", "^[!/](help)$", "^[!/](clean) (.*)$", "^[!/](demote) (.*)$", "^[!/](set) ([^%s]+) (.*)$", "^[!/](lock) (.*)$", "^[!/](setowner) (%d+)$", "^[!/](owner)$", "^[!/](res) (.*)$", "^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^[!/](unlock) (.*)$", "^[!/](setflood) (%d+)$", "^[!/](settings)$", "^[!/](modlist)$", "^[!/](newlink)$", "^[!/](link)$", "%[(photo)%]", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
KayMD/Illarion-Content
quest/iradona_goldschein_630_galmair.lua
3
2984
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- INSERT INTO "quests" ("qst_id", "qst_script") VALUES (630, 'quest.iradona_goldschein_630_galmair'); local common = require("base.common") local M = {} local GERMAN = Player.german local ENGLISH = Player.english -- Insert the quest title here, in both languages local Title = {} Title[GERMAN] = "Finde Lotta Medborgar in Galmair" Title[ENGLISH] = "Find Lotta Medborgar in Galmair" -- Insert an extensive description of each status here, in both languages -- Make sure that the player knows exactly where to go and what to do local Description = {} Description[GERMAN] = {} Description[ENGLISH] = {} Description[GERMAN][1] = "Finde Lotta Medborgar in Galmair and sprich mit ihr." Description[ENGLISH][1] = "Find Lotta Medborgar in Galmair and talk to her." Description[GERMAN][2] = "Du hast Lotta gefunden. Wenn du möchtest, kannst du nun mit ihr sprechen. Frage nach 'Hilfe' wenn du nicht weißt, wonach du fragen sollst!\nSie kann dir einiges über die nordwestliche Karte von Illarion verraten." Description[ENGLISH][2] = "You have found Lotta. If you like, you can talk with her now. Ask for 'help' if you do not know what to say!\nShe can provide you with information about the north-western part of Illarion." -- Insert the position of the quest start here (probably the position of an NPC or item) local Start = {428, 248, 0} -- For each status insert a list of positions where the quest will continue, i.e. a new status can be reached there local QuestTarget = {} QuestTarget[1] = {position(344, 249, 0)} -- entrance taverne (Scoria Mine) --QuestTarget[1] = {position(393, 326, -5)} -- Lotta (If set active, it would confuse a newbie because the lower levels of Galmair are not on the same spot as the surface level) -- Insert the quest status which is reached at the end of the quest local FINAL_QUEST_STATUS = 2 function M.QuestTitle(user) return common.GetNLS(user, Title[GERMAN], Title[ENGLISH]) end function M.QuestDescription(user, status) local german = Description[GERMAN][status] or "" local english = Description[ENGLISH][status] or "" return common.GetNLS(user, german, english) end function M.QuestStart() return Start end function M.QuestTargets(user, status) return QuestTarget[status] end function M.QuestFinalStatus() return FINAL_QUEST_STATUS end return M
agpl-3.0
gajop/Zero-K
LuaRules/Gadgets/weapon_area_damage.lua
11
3637
-------------------------------------------------------------------------------- -------------------------------------------------------------------------------- if not gadgetHandler:IsSyncedCode() then return end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- function gadget:GetInfo() return { name = "Area Denial", desc = "Lets a weapon's damage persist in an area", author = "KDR_11k (David Becker), Google Frog", date = "2007-08-26", license = "Public domain", layer = 21, enabled = true } end local frameNum local explosionList = {} local DAMAGE_PERIOD, weaponInfo = include("LuaRules/Configs/area_damage_defs.lua") --misc local rowCount = 0 --remember the lenght of explosionList table local emptyRow = {count=0} --remember empty position in explosionList table. -- function gadget:UnitPreDamaged_GetWantedWeaponDef() local wantedWeaponList = {} for wdid = 1, #WeaponDefs do if weaponInfo[wdid] then wantedWeaponList[#wantedWeaponList + 1] = wdid end end return wantedWeaponList end function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, attackerID, attackerDefID, attackerTeam) if weaponInfo[weaponDefID] and weaponInfo[weaponDefID].impulse then return 0 end return damage end function gadget:Explosion_GetWantedWeaponDef() local wantedList = {} for wdid,_ in pairs(weaponInfo) do wantedList[#wantedList + 1] = wdid end return wantedList end function gadget:Explosion(weaponID, px, py, pz, ownerID) if (weaponInfo[weaponID]) then local w = { radius = weaponInfo[weaponID].radius, damage = weaponInfo[weaponID].damage, impulse = weaponInfo[weaponID].impulse, expiry = frameNum + weaponInfo[weaponID].duration, rangeFall = weaponInfo[weaponID].rangeFall, timeLoss = weaponInfo[weaponID].timeLoss, id = weaponID, pos = {x = px, y = py, z = pz}, owner=ownerID, } if emptyRow.count > 0 then local emptyPos = emptyRow[emptyRow.count] emptyRow.count = emptyRow.count-1 if emptyPos then -- sometimes emptyPos is nil and this is worrying. emptyRow[emptyPos] = nil explosionList[emptyPos] = w --insert new data at empty position in explosionList table end else rowCount = rowCount + 1 explosionList[rowCount] = w --insert new data at a new position at end of explosionList table end end return false end local totalDamage = 0 function gadget:GameFrame(f) frameNum=f if (f%DAMAGE_PERIOD == 0) then for i,w in pairs(explosionList) do local pos = w.pos local ulist = Spring.GetUnitsInSphere(pos.x, pos.y, pos.z, w.radius) if (ulist) then for j=1, #ulist do local u = ulist[j] local ux, uy, uz = Spring.GetUnitPosition(u) local damage = w.damage if w.rangeFall ~= 0 then damage = damage - damage*w.rangeFall*math.sqrt((ux-pos.x)^2 + (uy-pos.y)^2 + (uz-pos.z)^2)/w.radius end if w.impulse then GG.AddGadgetImpulse(u, pos.x - ux, pos.y - uy, pos.z - uz, damage, false, true, false, {0.22,0.7,1}) GG.SetUnitFallDamageImmunity(u, f + 10) GG.DoAirDrag(u, damage) else Spring.AddUnitDamage(u, damage, 0, w.owner, w.id, 0, 0, 0) end end end w.damage = w.damage - w.timeLoss if f >= w.expiry then explosionList[i] = nil emptyRow.count = emptyRow.count + 1 emptyRow[emptyRow.count] = i --remember where is all empty position in explosionList table end end end end function gadget:Initialize() for w,_ in pairs(weaponInfo) do Script.SetWatchWeapon(w, true) end end
gpl-2.0
Mutos/NAEV-StarsOfCall
dat/missions/flf/flf_pre02.lua
4
18088
--[[ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -- This is the second "prelude" mission leading to the FLF campaign. stack variable flfbase_intro: 1 - The player has turned in the FLF agent or rescued the Dvaered crew. Conditional for dv_antiflf02 2 - The player has rescued the FLF agent. Conditional for flf_pre02 3 - The player has found the FLF base for the Dvaered, or has betrayed the FLF after rescuing the agent. Conditional for dv_antiflf03 --]] include "fleethelper.lua" include "dat/missions/flf/flf_patrol.lua" -- localization stuff, translators would work here lang = naev.lang() if lang == "es" then else -- default english title = {} text = {} DVtitle = {} DVtext = {} osd_desc = {} DVosd = {} refuelmsg = {} title[1] = "A chance to prove yourself" text[1] = [[The FLF officer doesn't seem at all surprised that you approached her. On the contrary, she looks like she expected you to do so all along. "Greetings," she says, nodding at you in curt greeting. "I am Corporal Benito. And you must be %s, the one who got Lt. Fletcher back here in one piece." Benito's expression becomes a little more severe. "I'm not here to exchange pleasantries, however. You probably noticed, but people here are a little uneasy about your presence. They don't know what to make of you, see. You helped us once, it is true, but that doesn't tell us much. We don't know you."]] text[2] = [[Indeed, you are constantly aware of the furtive glances the other people in this bar are giving you. They don't seem outright hostile, but you can tell that if you don't watch your step and choose your words carefully, things might quickly take a turn for the worse. Benito waves her hand to indicate you needn't pay them any heed. "That said, the upper ranks have decided that if you are truly sympathetic to our cause, you will be given an opportunity to prove yourself. Of course, if you'd rather not get involved in our struggle, that's understandable. But if you're in for greater things, if you stand for justice... Perhaps you'll consider joining with us?"]] title[3] = "Patrol-B-gone" text[3] = [["I'm happy to hear that. It's good to know we still have the support from the common man. Anyway, let me fill you in on what it is we want you to do. As you may be aware, the Dvaered have committed a lot of resources to finding us and flushing us out lately. And while our base is well hidden, those constant patrols are certainly not doing anything to make us feel more secure! I think you can see where this is going. You will go out there and eliminate one of those patrols in the %s system." You object, asking the Corporal if all recruits have to undertake dangerous missions like this to be accepted into the FLF ranks. Benito chuckles, and makes a pacifying gesture. "Calm down, it's not as bad as it sounds. You only have to take out one small patrol; I don't think you will have to fight more than 3 ships, 4 if you're really unlucky. If you think that's too much for you, you can abort the mission for now and come to me again later. Otherwise, good luck!"]] title[4] = "Breaking the ice" text[4] = [[When you left Sindbad Station, it was a cold, lonely place for you. The FLF soldiers on the station avoided you whenever they could, and basic services were harder to get than they should have been. But now that you have returned victorious over the Dvaered, the place has become considerably more hospitable. There are more smiles on people's faces, and some even tell you you did a fine job. Among them is Corporal Benito. She walks up to you and offers you her hand.]] text[5] = [["Welcome back, %s, and congratulations. I didn't expect the Dvaered to send reinforcements, much less a Vigilance. I certainly wouldn't have sent you alone if I did, and I might not have sent you at all. But then, you're still in one piece, so maybe I shouldn't worry so much, eh?"]] text[6] = [[Benito takes you to the station's bar, and buys you what for lack of a better word must be called a drink. "We will of course reward you for your service," she says once you are seated. "Though you must understand the FLF doesn't have that big a budget. Financial support is tricky, and the Frontier doesn't have that much to spare themselves to begin with. Nevertheless, we are willing to pay for good work, and your work is nothing but. What's more, you've ingratiated yourself with many of us, as you've undoubtedly noticed. Our top brass are among those you've impressed, so from today on, you can call yourself one of us! How about that, huh?"]] text[7] = [["Of course, our work is only just beginning. No rest for the weary; we must continue the fight against the oppressors. I'm sure the road is still long, but I'm encouraged by the fact that we gained another valuable ally today. Check the mission computer for more tasks you can help us with. I'm sure you'll play an important role in our eventual victory over the Dvaered!" That last part earns a cheer from the assembled FLF soldiers. You decide to raise your glass with them, making a toast to the fortune of battle in the upcoming campaign - and the sweet victory that lies beyond.]] refusetitle = "Some other time perhaps" refusetext = [["I see. That's a fair answer, I'm sure you have your reasons. But if you ever change your mind, I'll be around on Sindbad. You won't have trouble finding me, I'm sure."]] DVtitle[1] = "A tempting offer" DVtext[1] = [[Your viewscreen shows a Dvaered Colonel. He looks tense. Normally, a tense Dvaered would be bad news, but then this one bothered to hail you in the heat of battle, so perhaps there is more here than meets the eye.]] DVtext[2] = [["I am Colonel Urnus of the Dvaered Fleet, anti-terrorism division. I would normally never contact an enemy of House Dvaered, but my intelligence officer has looked through our records and found that you were recently a law-abiding citizen, doing honest freelance missions."]] DVtext[3] = [["I know your type, %s. You take jobs where profit is to be had, and you side with the highest bidder. There are many like you in the galaxy, though admittedly not so many with your talent. That's why I'm willing to make you this offer: you will provide us with information on their base of operations and their combat strength. In return, I will convince my superiors that you were working for me all along, so you won't face any repercussions for assaulting Dvaered ships. Furthermore, I will transfer a considerable amount of credits in your account, as well as put you into a position to make an ally out of House Dvaered. If you refuse, however, I guarantee you that you will never again be safe in Dvaered space. What say you? Surely this proposition beats anything that rabble can do for you?"]] DVchoice1 = "Accept the offer" DVchoice2 = "Remain loyal to the FLF" DVtitle[4] = "Opportunism is an art" DVtext[4] = [[Colonel Urnus smiles broadly. "I knew you'd make the right choice, citizen!" He addresses someone on his bridge, out of the view of the camera. "Notify the flight group. This ship is now friendly. Cease fire." Then he turns back to you. "Proceed to %s in the %s system, citizen. I will personally meet you there."]] DVtitle[5] = "End of negotiations" DVtext[5] = [[Colonel Urnus is visibly annoyed by your response. "Very well then," he bites at you. "In that case you will be destroyed along with the rest of that terrorist scum. Helm, full speed ahead! All batteries, fire at will!"]] DVtitle[6] = "A reward for a job well botched" DVtext[6] = [[Soon after docking, you are picked up by a couple of soldiers, who escort you to Colonel Urnus' office. Urnus greets you warmly, and offers you a seat and a cigar. You take the former, not the latter. "I am most pleased with the outcome of this situation, citizen," Urnus begins. "To be absolutely frank with you, I was beginning to get frustrated. My superiors have been breathing down my neck, demanding results on those blasted FLF, but they are as slippery as eels. Just when you think you've cornered them, poof! They're gone, lost in that nebula. Thick as soup, that thing. I don't know how they can even find their own way home!"]] DVtext[7] = [[Urnus takes a puff of his cigar and blows out a ring of smoke. It doesn't take a genius to figure out you're the best thing that's happened to him in a long time. "Anyway. I promised you money, status and opportunities, and I intend to make good on those promises. Your money is already in your account. Check your balance sheet later. As for status, I can assure you that no Dvaered will find out what you've been up to. As far as the military machine is concerned, you have nothing to do with the FLF. In fact, you're known as an important ally in the fight against them! Finally, opportunities. We're analyzing the data from your flight recorder as we speak, and you'll be asked a few questions after we're done here. Based on that, we can form a new strategy against the FLF. Unless I miss my guess by a long shot, we'll be moving against them in force very soon, and I will make sure you'll be given the chance to be part of that. I'm sure it'll be worth your while."]] DVtext[8] = [[Urnus stands up, a sign that this meeting is drawing to a close. "Keep your eyes open for one of our liaisons, citizen. He'll be your ticket into the upcoming battle. Now, I'm a busy man so I'm going to have to ask you to leave. But I hope we'll meet again, and if you continue to build your career like you have today, I'm sure we will. Good day to you!" You leave the Colonel's office. You are then taken to an interrogation room, where Dvaered petty officers question you politely yet persistently about your brief stay with the FLF. Once their curiosity is satisfied, they let you go, and you are free to return to your ship.]] flfcomm = {} flfcomm[1] = "We have your back, %s!" flfcomm[2] = "%s is selling us out! Eliminate the traitor!" flfcomm[3] = "Let's get out of here, %s! We'll meet you back at the base." misn_title = "FLF: Small Dvaered Patrol in %s" misn_desc = "To prove yourself to the FLF, you must take out one of the Dvaered security patrols." misn_rwrd = "A chance to make friends with the FLF." osd_title = "Dvaered Patrol" osd_desc[1] = "Fly to the %s system" osd_desc[2] = "Eliminate the Dvaered patrol" osd_desc[3] = "Return to the FLF base" osd_desc["__save"] = true DVosd[1] = "Fly to the %s system and land on %s" DVosd["__save"] = true npc_name = "FLF petty officer" npc_desc = "There is a low-ranking officer of the Frontier Liberation Front sitting at one of the tables. She seems somewhat more receptive than most people in the bar." end function create () missys = patrol_getTargetSystem() if not misn.claim( missys ) then misn.finish( false ) end misn.setNPC( npc_name, "flf/unique/benito" ) misn.setDesc( npc_desc ) end function accept () tk.msg( title[1], text[1]:format( player.name() ) ) if tk.yesno( title[1], text[2] ) then tk.msg( title[3], text[3]:format( missys:name() ) ) osd_desc[1] = osd_desc[1]:format( missys:name() ) misn.accept() misn.osdCreate( osd_title, osd_desc ) misn.setDesc( misn_desc ) misn.setTitle( misn_title:format( missys:name() ) ) marker = misn.markerAdd( missys, "low" ) misn.setReward( misn_rwrd ) DVplanet = "Raelid Outpost" DVsys = "Raelid" reinforcements_arrived = false dv_ships_left = 0 job_done = false hook.enter( "enter" ) hook.jumpout( "leave" ) hook.land( "leave" ) else tk.msg( refusetitle, refusetext ) misn.finish( false ) end end function enter () if not job_done then if system.cur() == missys then misn.osdActive( 2 ) patrol_spawnDV( 3, nil ) else misn.osdActive( 1 ) end end end function leave () if spawner ~= nil then hook.rm( spawner ) end if hailer ~= nil then hook.rm( hailer ) end if rehailer ~= nil then hook.rm( rehailer ) end reinforcements_arrived = false dv_ships_left = 0 end function spawnDVReinforcements () reinforcements_arrived = true local dist = 1500 local x local y if rnd.rnd() < 0.5 then x = dist else x = -dist end if rnd.rnd() < 0.5 then y = dist else y = -dist end local pos = player.pos() + vec2.new( x, y ) local reinforcements = pilot.add( "Dvaered Big Patrol", "dvaered_norun", pos ) for i, j in ipairs( reinforcements ) do if j:ship():class() == "Destroyer" then boss = j end hook.pilot( j, "death", "pilot_death_dv" ) j:setHostile() j:setVisible( true ) j:setHilight( true ) fleetDV[ #fleetDV + 1 ] = j dv_ships_left = dv_ships_left + 1 end -- Check for defection possibility if faction.playerStanding( "Dvaered" ) >= -5 then hailer = hook.timer( 30000, "timer_hail" ) else spawner = hook.timer( 30000, "timer_spawnFLF" ) end end function timer_hail () if hailer ~= nil then hook.rm( hailer ) end if boss ~= nil and boss:exists() then timer_rehail() hailer = hook.pilot( boss, "hail", "hail" ) end end function timer_rehail () if rehailer ~= nil then hook.rm( rehailer ) end if boss ~= nil and boss:exists() then boss:hailPlayer() rehailer = hook.timer( 8000, "timer_rehail" ) end end function hail () if hailer ~= nil then hook.rm( hailer ) end if rehailer ~= nil then hook.rm( rehailer ) end player.commClose() tk.msg( DVtitle[1], DVtext[1] ) tk.msg( DVtitle[1], DVtext[2] ) choice = tk.choice( DVtitle[1], DVtext[3]:format( player.name() ), DVchoice1, DVchoice2 ) if choice == 1 then tk.msg( DVtitle[4], DVtext[4]:format( DVplanet, DVsys ) ) faction.get("FLF"):modPlayerSingle( -200 ) local standing = faction.get("Dvaered"):playerStanding() if standing < 0 then faction.get("Dvaered"):modPlayerRaw( -standing ) end for i, j in ipairs( fleetDV ) do if j:exists() then j:setFriendly() j:changeAI( "dvaered" ) end end job_done = true osd_desc[1] = DVosd[1]:format( DVsys, DVplanet ) osd_desc[2] = nil misn.osdActive( 1 ) misn.osdCreate( misn_title, osd_desc ) misn.markerRm( marker ) marker = misn.markerAdd( system.get(DVsys), "high" ) spawner = hook.timer( 3000, "timer_spawnHostileFLF" ) hook.land( "land_dv" ) else tk.msg( DVtitle[5], DVtext[5] ) timer_spawnFLF() end end function spawnFLF () local dist = 1500 local x local y if rnd.rnd() < 0.5 then x = dist else x = -dist end if rnd.rnd() < 0.5 then y = dist else y = -dist end local pos = player.pos() + vec2.new( x, y ) fleetFLF = addShips( { "FLF Vendetta", "FLF Lancelot" }, "flf_norun", pos, 8 ) end function timer_spawnFLF () if boss ~= nil and boss:exists() then spawnFLF() for i, j in ipairs( fleetFLF ) do j:setFriendly() j:setVisplayer( true ) end fleetFLF[1]:broadcast( flfcomm[1]:format( player.name() ) ) end end function timer_spawnHostileFLF () spawnFLF() for i, j in ipairs( fleetFLF ) do j:setHostile() j:control() j:attack( player.pilot() ) end hook.pilot( player.pilot(), "death", "returnFLFControl" ) fleetFLF[1]:broadcast( flfcomm[2]:format( player.name() ) ) end function returnFLFControl() for i, j in ipairs( fleetFLF ) do j:control( false ) end end function pilot_death_dv () dv_ships_left = dv_ships_left - 1 if dv_ships_left <= 0 then if spawner ~= nil then hook.rm( spawner ) end if hailer ~= nil then hook.rm( hailer ) end if rehailer ~= nil then hook.rm( rehailer ) end job_done = true local standing = faction.get("Dvaered"):playerStanding() if standing >= 0 then faction.get("Dvaered"):modPlayerRaw( -standing - 1 ) end misn.osdActive( 3 ) misn.markerRm( marker ) marker = misn.markerAdd( system.get( var.peek( "flfbase_sysname" ) ), "high" ) hook.land( "land_flf" ) pilot.toggleSpawn( true ) local hailed = false if fleetFLF ~= nil then for i, j in ipairs( fleetFLF ) do if j:exists() then j:control() j:hyperspace() if not hailed then hailed = true j:comm( player.pilot(), flfcomm[3]:format( player.name() ) ) end end end end elseif dv_ships_left <= 1 and not reinforcements_arrived then spawnDVReinforcements() end end function land_flf () leave() if planet.cur():name() == "Sindbad" then tk.msg( title[4], text[4] ) tk.msg( title[4], text[5]:format( player.name() ) ) tk.msg( title[4], text[6] ) tk.msg( title[4], text[7] ) player.pay( 100000 ) faction.get("FLF"):modPlayer( 15 ) var.pop( "flfbase_sysname" ) var.pop( "flfbase_intro" ) misn.finish( true ) end end function land_dv () leave() if planet.cur():name() == DVplanet then tk.msg( DVtitle[6], DVtext[6] ) tk.msg( DVtitle[6], DVtext[7] ) tk.msg( DVtitle[6], DVtext[8] ) player.pay( 70000 ) var.push( "flfbase_intro", 3 ) if diff.isApplied( "FLF_base" ) then diff.remove( "FLF_base" ) end misn.finish( true ) end end
gpl-3.0
MOSAVI17/Anchor
plugins/img_google.lua
660
3196
do local mime = require("mime") local google_config = load_from_file('data/google.lua') local cache = {} --[[ local function send_request(url) local t = {} local options = { url = url, sink = ltn12.sink.table(t), method = "GET" } local a, code, headers, status = http.request(options) return table.concat(t), code, headers, status end]]-- local function get_google_data(text) local url = "http://ajax.googleapis.com/ajax/services/search/images?" url = url.."v=1.0&rsz=5" url = url.."&q="..URL.escape(text) url = url.."&imgsz=small|medium|large" if google_config.api_keys then local i = math.random(#google_config.api_keys) local api_key = google_config.api_keys[i] if api_key then url = url.."&key="..api_key end end local res, code = http.request(url) if code ~= 200 then print("HTTP Error code:", code) return nil end local google = json:decode(res) return google end -- Returns only the useful google data to save on cache local function simple_google_table(google) local new_table = {} new_table.responseData = {} new_table.responseDetails = google.responseDetails new_table.responseStatus = google.responseStatus new_table.responseData.results = {} local results = google.responseData.results for k,result in pairs(results) do new_table.responseData.results[k] = {} new_table.responseData.results[k].unescapedUrl = result.unescapedUrl new_table.responseData.results[k].url = result.url end return new_table end local function save_to_cache(query, data) -- Saves result on cache if string.len(query) <= 7 then local text_b64 = mime.b64(query) if not cache[text_b64] then local simple_google = simple_google_table(data) cache[text_b64] = simple_google end end end local function process_google_data(google, receiver, query) if google.responseStatus == 403 then local text = 'ERROR: Reached maximum searches per day' send_msg(receiver, text, ok_cb, false) elseif google.responseStatus == 200 then local data = google.responseData if not data or not data.results or #data.results == 0 then local text = 'Image not found.' send_msg(receiver, text, ok_cb, false) return false end -- Random image from table local i = math.random(#data.results) local url = data.results[i].unescapedUrl or data.results[i].url local old_timeout = http.TIMEOUT or 10 http.TIMEOUT = 5 send_photo_from_url(receiver, url) http.TIMEOUT = old_timeout save_to_cache(query, google) else local text = 'ERROR!' send_msg(receiver, text, ok_cb, false) end end function run(msg, matches) local receiver = get_receiver(msg) local text = matches[1] local text_b64 = mime.b64(text) local cached = cache[text_b64] if cached then process_google_data(cached, receiver, text) else local data = get_google_data(text) process_google_data(data, receiver, text) end end return { description = "Search image with Google API and sends it.", usage = "!img [term]: Random search an image with Google API.", patterns = { "^!img (.*)$" }, run = run } end
gpl-2.0
KayMD/Illarion-Content
triggerfield/donation_cadomyr.lua
4
1768
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- INSERT INTO triggerfields VALUES (115,520,0,'triggerfield.donation_cadomyr'); -- INSERT INTO triggerfields VALUES (115,521,0,'triggerfield.donation_cadomyr'); -- INSERT INTO triggerfields VALUES (116,520,0,'triggerfield.donation_cadomyr'); -- INSERT INTO triggerfields VALUES (116,521,0,'triggerfield.donation_cadomyr'); local common = require("base.common") local donation_base = require("triggerfield.base.donation") local M = {} -- Donation to the Cadomyr treasury -- 115, 552, 0 = Cadomyr function M.PutItemOnField(Item,User) local donated = donation_base.donate(Item, User, "Cadomyr", "Rosaline Edwards", "TreasureCadomyr") -- That's all folks -- Quest 151 (Cadomyr Treasury, NPC Ioannes Faber) if (donated) and (User:getQuestProgress(151) == 1) then User:setQuestProgress(151, 2) --Quest solved! common.InformNLS(User, "[Queststatus] Du hast den Befehl erfolgreich ausgeführt. Kehre zu Ioannes Faber zurück, um deine Belohnung einzufordern.", "[Quest status] You completed your task successfully. Return to Ioannes Faber to claim your reward.") end end return M
agpl-3.0
shahabsaf1/EMC-Project
bot/utils.lua
28
14994
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(user_id) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end -- user has admins privileges function is_admin(user_id, chat_id) local var = false local data = load_data(_config.moderation.data) if data[tostring('admins')] then if data[tostring('admins')][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end -- user has moderator privileges function is_mod(user_id, chat_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(chat_id)] then if data[tostring(chat_id)]['moderators'] then if data[tostring(chat_id)]['moderators'][tostring(user_id)] then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end function is_banned(user_id, chat_id) return redis:get('banned:'..chat_id..':'..user_id) or false end function is_super_banned(user_id) return redis:get('superbanned:'..user_id) or false end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = '' --'This plugin requires privileged user.' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) -- If plugins moderated = true if plugin.moderated and not is_mod(msg.from.id, msg.to.id) then -- Check if user is a mod if plugin.moderated and not is_admin(msg.from.id, msg.to.id) then -- Check if user is an admin if plugin.moderated and not is_sudo(msg.from.id) then -- Check if user is a sudoer return false end end end -- If plugins privileged = true if plugin.privileged and not is_sudo(msg.from.id) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end
gpl-2.0
miralireza2/gpf
plugins/webshot.lua
919
1473
local helpers = require "OAuth.helpers" local base = 'https://screenshotmachine.com/' local url = base .. 'processor.php' local function get_webshot_url(param) local response_body = {} local request_constructor = { url = url, method = "GET", sink = ltn12.sink.table(response_body), headers = { referer = base, dnt = "1", origin = base, ["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" }, redirect = false } local arguments = { urlparam = param, size = "FULL" } request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments) local ok, response_code, response_headers, response_status_line = https.request(request_constructor) if not ok or response_code ~= 200 then return nil end local response = table.concat(response_body) return string.match(response, "href='(.-)'") end local function run(msg, matches) local find = get_webshot_url(matches[1]) if find then local imgurl = base .. find local receiver = get_receiver(msg) send_photo_from_url(receiver, imgurl) end end return { description = "Send an screenshot of a website.", usage = { "!webshot [url]: Take an screenshot of the web and send it back to you." }, patterns = { "^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$", }, run = run }
gpl-2.0
kiarash14/BumperTG
plugins/webshot.lua
919
1473
local helpers = require "OAuth.helpers" local base = 'https://screenshotmachine.com/' local url = base .. 'processor.php' local function get_webshot_url(param) local response_body = {} local request_constructor = { url = url, method = "GET", sink = ltn12.sink.table(response_body), headers = { referer = base, dnt = "1", origin = base, ["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36" }, redirect = false } local arguments = { urlparam = param, size = "FULL" } request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments) local ok, response_code, response_headers, response_status_line = https.request(request_constructor) if not ok or response_code ~= 200 then return nil end local response = table.concat(response_body) return string.match(response, "href='(.-)'") end local function run(msg, matches) local find = get_webshot_url(matches[1]) if find then local imgurl = base .. find local receiver = get_receiver(msg) send_photo_from_url(receiver, imgurl) end end return { description = "Send an screenshot of a website.", usage = { "!webshot [url]: Take an screenshot of the web and send it back to you." }, patterns = { "^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$", }, run = run }
gpl-2.0
kiarash14/BumperTG
plugins/time.lua
771
2865
-- Implement a command !time [area] which uses -- 2 Google APIs to get the desired result: -- 1. Geocoding to get from area to a lat/long pair -- 2. Timezone to get the local time in that lat/long location -- Globals -- If you have a google api key for the geocoding/timezone api api_key = nil base_api = "https://maps.googleapis.com/maps/api" dateFormat = "%A %d %B - %H:%M:%S" -- Need the utc time for the google api function utctime() return os.time(os.date("!*t")) end -- Use the geocoding api to get the lattitude and longitude with accuracy specifier -- CHECKME: this seems to work without a key?? function get_latlong(area) local api = base_api .. "/geocode/json?" local parameters = "address=".. (URL.escape(area) or "") if api_key ~= nil then parameters = parameters .. "&key="..api_key end -- Do the request local res, code = https.request(api..parameters) if code ~=200 then return nil end local data = json:decode(res) if (data.status == "ZERO_RESULTS") then return nil end if (data.status == "OK") then -- Get the data lat = data.results[1].geometry.location.lat lng = data.results[1].geometry.location.lng acc = data.results[1].geometry.location_type types= data.results[1].types return lat,lng,acc,types end end -- Use timezone api to get the time in the lat, -- Note: this needs an API key function get_time(lat,lng) local api = base_api .. "/timezone/json?" -- Get a timestamp (server time is relevant here) local timestamp = utctime() local parameters = "location=" .. URL.escape(lat) .. "," .. URL.escape(lng) .. "&timestamp="..URL.escape(timestamp) if api_key ~=nil then parameters = parameters .. "&key="..api_key end local res,code = https.request(api..parameters) if code ~= 200 then return nil end local data = json:decode(res) if (data.status == "ZERO_RESULTS") then return nil end if (data.status == "OK") then -- Construct what we want -- The local time in the location is: -- timestamp + rawOffset + dstOffset local localTime = timestamp + data.rawOffset + data.dstOffset return localTime, data.timeZoneId end return localTime end function getformattedLocalTime(area) if area == nil then return "The time in nowhere is never" end lat,lng,acc = get_latlong(area) if lat == nil and lng == nil then return 'It seems that in "'..area..'" they do not have a concept of time.' end local localTime, timeZoneId = get_time(lat,lng) return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime) end function run(msg, matches) return getformattedLocalTime(matches[1]) end return { description = "Displays the local time in an area", usage = "!time [area]: Displays the local time in that area", patterns = {"^!time (.*)$"}, run = run }
gpl-2.0
ESMAILESMAIL/su
plugins/moderation.lua
42
30441
-------------------------------------------------- -- ____ ____ _____ -- -- | \| _ )_ _|___ ____ __ __ -- -- | |_ ) _ \ | |/ ·__| _ \_| \/ | -- -- |____/|____/ |_|\____/\_____|_/\/\_| -- -- -- -------------------------------------------------- -- -- -- Developers: @Josepdal & @MaSkAoS -- -- Support: @Skneos, @iicc1 & @serx666 -- -- -- -------------------------------------------------- do local function index_gban(user_id) for k,v in pairs(_gbans.gbans_users) do if tonumber(user_id) == tonumber(v) then return k end end -- If not found return false end local function unmute_by_reply(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local name = msg.from.username local hash = 'muted:'..chat..':'..user redis:del(hash) if msg.to.type == 'chat' then send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'userUnmuted:1')..' '..name..' ('..user..') '..lang_text(chat, 'userUnmuted:2'), ok_cb, true) elseif msg.to.type == 'channel' then send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'userUnmuted:1')..' '..name..' ('..user..') '..lang_text(chat, 'userUnmuted:2'), ok_cb, true) end end local function mute_by_reply(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local name = msg.from.username local hash = 'muted:'..chat..':'..user redis:set(hash, true) if msg.to.type == 'chat' then send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'userMuted:1')..' '..name..' ('..user..') '..lang_text(chat, 'userMuted:2'), ok_cb, true) elseif msg.to.type == 'channel' then send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'userMuted:1')..' '..name..' ('..user..') '..lang_text(chat, 'userMuted:2'), ok_cb, true) end end local function mute_by_username(cb_extra, success, result) chat_type = cb_extra.chat_type chat_id = cb_extra.chat_id user_id = result.peer_id user_username = result.username local hash = 'muted:'..chat_id..':'..user_id redis:set(hash, true) if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..user_username..' ('..user_id..') '..lang_text(chat_id, 'userMuted:2'), ok_cb, true) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..user_username..' ('..user_id..') '..lang_text(chat_id, 'userMuted:2'), ok_cb, true) end end local function unmute_by_username(cb_extra, success, result) chat_type = cb_extra.chat_type chat_id = cb_extra.chat_id user_id = result.peer_id user_username = result.username local hash = 'muted:'..chat_id..':'..user_id redis:del(hash) if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..user_username..' ('..user_id..') '..lang_text(chat_id, 'userUnmuted:2'), ok_cb, true) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..user_username..' ('..user_id..') '..lang_text(chat_id, 'userUnmuted:2'), ok_cb, true) end end local function kick_user(user_id, chat_id) local chat = 'chat#id'..chat_id local user = 'user#id'..user_id local channel = 'channel#id'..chat_id if user_id == tostring(our_id) then print("I won't kick myself!") else chat_del_user(chat, user, ok_cb, true) channel_kick_user(channel, user, ok_cb, true) end end local function ban_user(user_id, chat_id) local chat = 'chat#id'..chat_id if user_id == tostring(our_id) then print('I won\'t kick myself!') else -- Save to redis local hash = 'banned:'..chat_id..':'..user_id redis:set(hash, true) end end local function unban_user(user_id, chat_id) local hash = 'banned:'..chat_id..':'..user_id redis:del(hash) end local function is_banned(user_id, chat_id) local hash = 'banned:'..chat_id..':'..user_id local banned = redis:get(hash) return banned or false end local function chat_kick(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local chat_type = msg.to.type if chat_type == 'chat' then chat_del_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'kickUser:1')..' '..user..' '..lang_text(chat, 'kickUser:2'), ok_cb, true) elseif chat_type == 'channel' then channel_kick_user('channel#id'..chat, 'user#id'..user, ok_cb, false) send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'kickUser:1')..' '..user..' '..lang_text(chat, 'kickUser:2'), ok_cb, true) end end local function chat_ban(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local hash = 'banned:'..chat..':'..user redis:set(hash, true) chat_del_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'banUser:1')..' '..user..' '..lang_text(chat, 'banUser:2'), ok_cb, true) end local function gban_by_reply(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local hash = 'gban:'..user redis:set(hash, true) if not is_gbanned_table(msg.to.id) then table.insert(_gbans.gbans_users, tonumber(msg.to.id)) print(msg.to.id..' added to _gbans table') save_gbans() end if msg.to.type == 'chat' then chat_del_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'gbanUser:1')..' '..user..' '..lang_text(chat, 'gbanUser:2'), ok_cb, true) elseif msg.to.type == 'channel' then channel_kick_user('channel#id'..chat, 'user#id'..user, ok_cb, false) send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'gbanUser:1')..' '..user..' '..lang_text(chat, 'gbanUser:2'), ok_cb, true) end end local function ungban_by_reply(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id local indexid = index_gban(user) local hash = 'gban:'..user redis:del(hash) if is_gbanned_table(user_id) then table.remove(_gbans.gbans_users, indexid) print(user_id..' removed from _gbans table') save_gbans() end if msg.to.type == 'chat' then chat_add_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'ungbanUser:1')..' '..user..' '..lang_text(chat, 'ungbanUser:2'), ok_cb, true) elseif msg.to.type == 'channel' then channel_invite_user('channel#id'..chat, 'user#id'..user, ok_cb, false) send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'ungbanUser:1')..' '..user..' '..lang_text(chat, 'ungbanUser:2'), ok_cb, true) end end local function add_by_reply(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id if msg.to.type == 'chat' then chat_add_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg('chat#id'..chat, 'ℹ️ '..lang_text(chat, 'addUser:1')..' '..user..' '..lang_text(chat, 'addUser:2'), ok_cb, true) elseif msg.to.type == 'channel' then channel_invite_user('channel#id'..chat, 'user#id'..user, ok_cb, false) send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'addUser:1')..' '..user..' '..lang_text(chat, 'addUser:3'), ok_cb, true) end end local function channel_ban(extra, success, result) local msg = result msg = backward_msg_format(msg) local chat = msg.to.id local user = msg.from.id channel_kick_user('channel#id'..chat, 'user#id'..user, ok_cb, true) send_msg('channel#id'..chat, 'ℹ️ '..lang_text(chat, 'banUser:1')..' '..user..' '..lang_text(chat, 'banUser:2'), ok_cb, true) ban_user(user, chat) end local function chat_unban(extra, success, result) result = backward_msg_format(result) local msg = result local chat = msg.to.id local user = msg.from.id unban_user(user, chat) chat_add_user('chat#id'..chat, 'user#id'..user, ok_cb, false) send_msg(chat, 'User '..user..' unbanned', ok_cb, true) end local function channel_unban(extra, success, result) local msg = result local msg = backward_msg_format(msg) local chat = msg.to.id local user = msg.from.id unban_user(user, chat) channel_invite_user('channel#id'..chat, 'user#id'..user, ok_cb, true) send_msg('channel#id'..chat, 'User '..user..' unbanned', ok_cb, true) end local function ban_by_username(cb_extra, success, result) chat_type = cb_extra.chat_type chat_id = cb_extra.chat_id user_id = result.peer_id user_username = result.username local hash = 'banned:'..chat_id..':'..user_id redis:set(hash, true) if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'banUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'banUser:2'), ok_cb, false) chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'banUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'banUser:2'), ok_cb, false) channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end ban_user(user_id, chat_id) end local function kick_by_username(cb_extra, success, result) chat_id = cb_extra.chat_id user_id = result.peer_id chat_type = cb_extra.chat_type user_username = result.username if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'kickUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'kickUser:2'), ok_cb, false) chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'kickUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'kickUser:2'), ok_cb, false) channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end end local function gban_by_username(cb_extra, success, result) local chat_id = cb_extra.chat_id local user_id = result.peer_id local user_username = result.username local chat_type = cb_extra.chat_type local hash = 'gban:'..user_id redis:set(hash, true) if not is_gbanned_table(user_id) then table.insert(_gbans.gbans_users, tonumber(user_id)) print(user_id..' added to _gbans table') save_gbans() end if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'gbanUser:2'), ok_cb, false) chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'gbanUser:2'), ok_cb, false) channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end end local function ungban_by_username(cb_extra, success, result) chat_id = cb_extra.chat_id user_id = result.peer_id user_username = result.username chat_type = cb_extra.chat_type local indexid = index_gban(user_id) local hash = 'gban:'..user_id redis:del(hash) if is_gbanned_table(user_id) then table.remove(_gbans.gbans_users, indexid) print(user_id..' removed from _gbans table') save_gbans() end if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'ungbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'ungbanUser:2'), ok_cb, false) chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'ungbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'ungbanUser:2'), ok_cb, false) channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end end local function unban_by_username(cb_extra, success, result) chat_type = cb_extra.chat_type chat_id = cb_extra.chat_id user_id = result.peer_id user_username = result.username local hash = 'banned:'..chat_id..':'..user_id redis:del(hash) if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'unbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'unbanUser:2'), ok_cb, false) chat_add_user('chat#id'..chat_id, 'user#id'..user_id, callback, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'unbanUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'unbanUser:2'), ok_cb, false) channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, callback, false) end end local function add_by_username(cb_extra, success, result) local chat_type = cb_extra.chat_type local chat_id = cb_extra.chat_id local user_id = result.peer_id local user_username = result.username print(chat_id) if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'addUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'addUser:2'), ok_cb, false) chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'addUser:1')..' @'..user_username..' ('..user_id..') '..lang_text(chat_id, 'addUser:3'), ok_cb, false) channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end end local function is_gbanned(user_id) local hash = 'gban:'..user_id local banned = redis:get(hash) return banned or false end local function pre_process(msg) --Checking mute local hash = 'muted:'..msg.to.id..':'..msg.from.id if redis:get(hash) then if msg.to.type == 'chat' then delete_msg(msg.id, ok_cb, true) elseif msg.to.type == 'channel' then delete_msg(msg.id, ok_cb, true) end end -- SERVICE MESSAGE if msg.action and msg.action.type then local action = msg.action.type -- Check if banned user joins chat if action == 'chat_add_user' or action == 'chat_add_user_link' then local user_id local hash = 'lockmember:'..msg.to.id if redis:get(hash) then if msg.action.link_issuer then user_id = msg.from.id else user_id = msg.action.user.id end kick_user(user_id, msg.to.id) delete_msg(msg.id, ok_cb, true) end if msg.action.link_issuer then user_id = msg.from.id else user_id = msg.action.user.id end print('Checking invited user '..user_id) local banned = is_banned(user_id, msg.to.id) or is_gbanned(user_id) if banned then print('User is banned!') kick_user(user_id, msg.to.id) end end -- No further checks return msg end -- BANNED USER TALKING if msg.to.type == 'chat' or msg.to.type == 'channel' then local user_id = msg.from.id local chat_id = msg.to.id local banned = is_banned(user_id, chat_id) or is_gbanned(user_id, msg.to.id) if banned then print('Banned user talking!') ban_user(user_id, chat_id) kick_user(user_id, chat_id) msg.text = '' end hash = 'antibot:'..msg.to.id if redis:get(hash) then if string.sub(msg.from.username, (string.len(msg.from.username)-2), string.len(msg.from.username)) == 'bot' then kick_user(user_id, chat_id) end end end return msg end local function run(msg, matches) chat_id = msg.to.id if matches[1] == 'ban' then if permissions(msg.from.id, msg.to.id, "ban") then local chat_id = msg.to.id local chat_type = msg.to.type if msg.reply_id then if msg.to.type == 'chat' then get_message(msg.reply_id, chat_ban, false) elseif msg.to.type == 'channel' then get_message(msg.reply_id, channel_ban, {receiver=get_receiver(msg)}) end return end if not is_id(matches[2]) then local member = string.gsub(matches[2], '@', '') resolve_username(member, ban_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else user_id = matches[2] if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'banUser:1')..' '..user_id..' '..lang_text(chat, 'banUser:2'), ok_cb, false) chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'banUser:1')..' '..user_id..' '..lang_text(chat, 'banUser:2'), ok_cb, false) channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end ban_user(user_id, chat_id) return end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'unban' then if permissions(msg.from.id, msg.to.id, "unban") then local chat_id = msg.to.id local chat_type = msg.to.type if msg.reply_id then if msg.to.type == 'chat' then get_message(msg.reply_id, chat_unban, false) elseif msg.to.type == 'channel' then get_message(msg.reply_id, channel_unban, false) end return end if not is_id(matches[2]) then local member = string.gsub(matches[2], '@', '') resolve_username(member, unban_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else local hash = 'banned:'..chat_id..':'..matches[2] redis:del(hash) if msg.to.type == 'chat' then chat_add_user('chat#id'..chat_id, 'user#id'..matches[2], ok_cb, false) elseif msg.to.type == 'channel' then channel_invite_user('channel#id'..chat_id, 'user#id'..matches[2], ok_cb, false) end return 'ℹ️ '..lang_text(chat_id, 'unbanUser:1')..' '..matches[2]..' '..lang_text(chat_id, 'unbanUser:2') end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'kick' then if permissions(msg.from.id, msg.to.id, "kick") then local chat_id = msg.to.id local chat_type = msg.to.type -- Using pattern #kick if msg.reply_id then get_message(msg.reply_id, chat_kick, false) return end if not is_id(matches[2]) then local member = string.gsub(matches[2], '@', '') resolve_username(member, kick_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else local user_id = matches[2] if msg.to.type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'kickUser:1')..' '..user_id..' '..lang_text(chat_id, 'kickUser:2'), ok_cb, false) chat_del_user('chat#id'..msg.to.id, 'user#id'..matches[2], ok_cb, false) elseif msg.to.type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'kickUser:1')..' '..user_id..' '..lang_text(chat_id, 'kickUser:2'), ok_cb, false) channel_kick_user('channel#id'..msg.to.id, 'user#id'..matches[2], ok_cb, false) end return end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'gban' then if permissions(msg.from.id, msg.to.id, "gban") then chat_id = msg.to.id chat_type = msg.to.type if msg.reply_id then get_message(msg.reply_id, gban_by_reply, false) return end if not is_id(matches[2]) then local member = string.gsub(matches[2], '@', '') resolve_username(member, gban_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else local user_id = matches[2] local hash = 'gban:'..user_id redis:set(hash, true) if not is_gbanned_table(user_id) then table.insert(_gbans.gbans_users, tonumber(user_id)) print(user_id..' added to _gbans table') save_gbans() end if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' '..user_id..' '..lang_text(chat_id, 'gbanUser:2'), ok_cb, false) chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' '..user_id..' '..lang_text(chat_id, 'gbanUser:2'), ok_cb, false) channel_kick_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end return end else return '🚫 '..lang_text(msg.to.id, 'require_admin') end elseif matches[1] == 'ungban' then if permissions(msg.from.id, msg.to.id, "ungban") then chat_id = msg.to.id chat_type = msg.to.type if msg.reply_id then get_message(msg.reply_id, ungban_by_reply, false) return end if not is_id(matches[2]) then local chat_type = msg.to.type local member = string.gsub(matches[2], '@', '') resolve_username(member, ungban_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else local user_id = matches[2] local hash = 'gban:'..user_id local indexid = index_gban(user_id) redis:del(hash) if is_gbanned_table(user_id) then table.remove(_gbans.gbans_users, indexid) print(user_id..' removed from _gbans table') save_gbans() end if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' '..user_id..' '..lang_text(chat_id, 'ungbanUser:2'), ok_cb, false) chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'gbanUser:1')..' '..user_id..' '..lang_text(chat_id, 'ungbanUser:2'), ok_cb, false) channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end return end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'add' then if permissions(msg.from.id, msg.to.id, "add") then local chat_id = msg.to.id local chat_type = msg.to.type if msg.reply_id then get_message(msg.reply_id, add_by_reply, false) return end if not is_id(matches[2]) then local member = string.gsub(matches[2], '@', '') print(chat_id) resolve_username(member, add_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return else local user_id = matches[2] if chat_type == 'chat' then send_msg('chat#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'addUser:1')..' '..user_id..' '..lang_text(chat_id, 'addUser:2'), ok_cb, false) chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) elseif chat_type == 'channel' then send_msg('channel#id'..chat_id, 'ℹ️ '..lang_text(chat_id, 'addUser:1')..' '..user_id..' '..lang_text(chat_id, 'addUser:3'), ok_cb, false) channel_invite_user('channel#id'..chat_id, 'user#id'..user_id, ok_cb, false) end return end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'mute' then if permissions(msg.from.id, msg.to.id, "mute") then if msg.reply_id then get_message(msg.reply_id, mute_by_reply, false) return end if matches[2] then if is_id(matches[2]) then local hash = 'muted:'..msg.to.id..':'..matches[2] redis:set(hash, true) if msg.to.type == 'chat' then send_msg('chat#id'..msg.to.id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..matches[2]..' '..lang_text(chat_id, 'userMuted:2'), ok_cb, true) elseif msg.to.type == 'channel' then send_msg('channel#id'..msg.to.id, 'ℹ️ '..lang_text(chat_id, 'userMuted:1')..' '..matches[2]..' '..lang_text(chat_id, 'userMuted:2'), ok_cb, true) end return else local member = string.gsub(matches[2], '@', '') local chat_id = msg.to.id local chat_type = msg.to.type resolve_username(member, mute_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return end end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'unmute' then if permissions(msg.from.id, msg.to.id, "unmute") then if msg.reply_id then get_message(msg.reply_id, unmute_by_reply, false) return end if matches[2] then if is_id(matches[2]) then local hash = 'muted:'..msg.to.id..':'..matches[2] redis:del(hash) if msg.to.type == 'chat' then send_msg('chat#id'..msg.to.id, 'ℹ️ '..lang_text(chat_id, 'userUnmuted:1')..' '..matches[2]..' '..lang_text(chat_id, 'userUnmuted:2'), ok_cb, true) elseif msg.to.type == 'channel' then send_msg('channel#id'..msg.to.id, 'ℹ️ '..lang_text(chat_id, 'userUnmuted:1')..' '..matches[2]..' '..lang_text(chat_id, 'userUnmuted:2'), ok_cb, true) end return else local member = string.gsub(matches[2], '@', '') local chat_id = msg.to.id local chat_type = msg.to.type resolve_username(member, unmute_by_username, {chat_id=chat_id, member=member, chat_type=chat_type}) return end end else return '🚫 '..lang_text(msg.to.id, 'require_mod') end elseif matches[1] == 'kickme' then local hash = 'kickme:'..msg.to.id if redis:get(hash) then if msg.to.type == 'chat' then send_msg('chat#id'..msg.to.id, '👋🏽 '..lang_text(chat_id, 'kickmeBye')..' @'..msg.from.username..' ('..msg.from.id..').', ok_cb, true) chat_del_user('chat#id'..msg.to.id, 'user#id'..msg.from.id, ok_cb, false) elseif msg.to.type == 'channel' then send_msg('channel#id'..msg.to.id, '👋🏽 '..lang_text(chat_id, 'kickmeBye')..' @'..msg.from.username..' ('..msg.from.id..').', ok_cb, true) channel_kick_user('channel#id'..msg.to.id, 'user#id'..msg.from.id, ok_cb, false) end end end end return { patterns = { "^[!/#](ban) (.*)$", "^[!/#](ban)$", "^[!/#](unban) (.*)$", "^[!/#](unban)$", "^[!/#](kick) (.*)$", "^[!/#](kick)$", "^[!/#](kickme)$", "^[!/#](add) (.*)$", "^[!/#](add)$", "^[!/#](gban) (.*)$", "^[!/#](gban)$", "^[!/#](ungban) (.*)$", "^[!/#](ungban)$", '^[!/#](mute) (.*)$', '^[!/#](mute)$', '^[!/#](unmute) (.*)$', '^[!/#](unmute)$', "^!!tgservice (.*)$" }, run = run, pre_process = pre_process } end
gpl-2.0
KayMD/Illarion-Content
npc/base/consequence/arena.lua
3
1856
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] local class = require("base.class") local consequence = require("npc.base.consequence.consequence") local base_arena = require("base.arena") local ranklist = require("base.ranklist") local arena_timer = require("lte.arena_timer") local _arena_helper_request local _arena_helper_points local _arena_helper_list local arena = class(consequence, function(self, mode) consequence:init(self) self["mode"] = mode if (mode == "request") then self["perform"] = _arena_helper_request elseif (mode == "points") then self["perform"] = _arena_helper_points elseif (mode == "list") then self["perform"] = _arena_helper_list else -- unkonwn comparator end end) function _arena_helper_request(self, npcChar, player) base_arena.requestMonster(player, npcChar) end function _arena_helper_points(self, npcChar, player) base_arena.getArenastats(player, npcChar) end function _arena_helper_list(self, npcChar, player) local arena = base_arena.getArena(player, npcChar) local town = base_arena.arenaInformation[arena].town local arenaListName = "ArenaList"..town ranklist.getRanklist(player, arenaListName, true) end return arena
agpl-3.0
torhve/ivar2
modules/title/init.lua
1
11482
--- HTML Title resolving module local util = require'util' local simplehttp = util.simplehttp local trim = util.trim local uri_parse = util.uri_parse local iconv = require"iconv" local html2unicode = require'html' local lfs = require'lfs' local exif = require'exif' local googlevision = require'googlevision' -- requires google vision cloud API key local DL_LIMIT = 2^24 -- 16 MiB local gvision_apikey = ivar2.config.cloudvisionAPIKey or 'AIzaSyBTLSPVnk6yUFTm8USlCOIxEqbkOpAauxQ' local patterns = { -- X://Y url "^(https?://%S+)", "^<(https?://%S+)>", "%f[%S](https?://%S+)", -- www.X.Y url "^(www%.[%w_-%%]+%.%S+)", "%f[%S](www%.[%w_-%%]+%.%S+)", } local translateCharset = { utf8 = 'utf-8', ['x-sjis'] = 'sjis', ['ks_c_5601-1987'] = 'euc-kr', ['ksc_5601'] = 'euc-kr', } -- RFC 2396, section 1.6, 2.2, 2.3 and 2.4.1. local smartEscape = function(str) local pathOffset = str:match("//[^/]+/()") -- No path means nothing to escape. if(not pathOffset) then return str end local prePath = str:sub(1, pathOffset - 1) -- lowalpha: a-z | upalpha: A-Z | digit: 0-9 | mark: -_.!~*'() | -- reserved: ;/?:@&=+$, | delims: <>#%" | unwise: {}|\^[]` | space: <20> local pattern = '[^a-zA-Z0-9%-_%.!~%*\'%(%);/%?:@&=%+%$,<>#%%"{}|\\%^%[%] ]' local path = str:sub(pathOffset):gsub(pattern, function(c) return ('%%%02X'):format(c:byte()) end) return prePath .. path end local parseAJAX do local escapedChars = {} local q = function(i) escapedChars[string.char(i)] = string.format('%%%X', i) end for i=0, tonumber(20, 16) do q(i) end for i=tonumber('7F', 16), tonumber('FF', 16) do q(i) end q(tonumber(23, 16)) q(tonumber(25, 16)) q(tonumber(26, 16)) q(tonumber('2B', 16)) function parseAJAX(url) local offset, shebang = url:match('()#!(.+)$') if(offset) then url = url:sub(1, offset - 1) shebang = shebang:gsub('([%z\1-\127\194-\244][\128-\191]*)', escapedChars) url = url .. '?_escaped_fragment_=' .. shebang end return url end end local verify = function(charset) if(charset) then charset = charset:lower() charset = translateCharset[charset] or charset return charset end end local guessCharset = function(headers, data) local charset -- BOM: local bom4 = data:sub(1,4) local bom2 = data:sub(1,2) if(data:sub(1,3) == '\239\187\191') then return 'utf-8' elseif(bom4 == '\255\254\000\000') then return 'utf-32le' elseif(bom4 == '\000\000\254\255') then return 'utf-32be' elseif(bom4 == '\254\255\000\000') then return 'x-iso-10646-ucs-4-3412' elseif(bom4 == '\000\000\255\254') then return 'x-iso-10646-ucs-4-2143' elseif(bom2 == '\255\254') then return 'utf-16le' elseif(bom2 == '\254\255') then return 'utf-16be' end -- TODO: tell user if it's downloadable stuff, other mimetype, like PDF or whatever -- Header: local contentType = headers['content-type'] if(contentType and contentType:match'charset') then charset = verify(contentType:match('charset=([^;]+)')) if(charset) then return charset end end -- XML: charset = verify(data:match('<%?xml .-encoding=[\'"]([^\'"]+)[\'"].->')) if(charset) then return charset end -- HTML5: charset = verify(data:match('<meta charset=[\'"]([\'"]+)[\'"]>')) if(charset) then return charset end -- HTML: charset = data:lower():match('<meta.-content=[\'"].-(charset=.-)[\'"].->') if(charset) then charset = verify(charset:match'=([^;]+)') if(charset) then return charset end end end local limitOutput = function(str) local limit = 300 if(#str > limit) then str = str:sub(1, limit) if(#str == limit) then -- Clip it at the last space: str = str:match('^.* ') .. '…' end end return str end local handleExif = function(data) -- Try to get interesting exif information from a blob of data -- local exif_tags = {} local interesting_exif_tags = {'Make', 'Model','ISOSpeedRatings', 'ExposureTime', 'FNumber', 'FocalLength', 'DateTimeOriginal', } local exif_data = exif.loadbuffer(data) for i, ifd in pairs(exif_data:ifds()) do for j, entry in pairs(ifd:entries()) do for _, tag in pairs(interesting_exif_tags) do print(entry.tag, entry.value) if entry.tag == tag and entry.value then local value = entry.value if tag == 'ISOSpeedRatings' then value = string.format('ISO %s', value) end exif_tags[#exif_tags+1] = value end end end end local function toDecimal(d1, m1, s1, d2, m2, s2, ns, ew) local sign = 1 if ns == 'S' then sign = -1 end local decDeg1 = sign*(d1 + m1/60 + s1/3600) sign = 1 if ew == 'W' then sign = -1 end local decDeg2 = sign*(d2 + m2/60 + s2/3600) return decDeg1, decDeg2 end local lat_ref = exif_data:ifd("GPS"):entry('GPSLatitudeRef') local lon_ref = exif_data:ifd("GPS"):entry('GPSLongitudeRef') local lat = exif_data:ifd("GPS"):entry('GPSLatitude') local lon = exif_data:ifd("GPS"):entry('GPSLongitude') local lat_split = util.split(tostring(lat), ', ') local lon_split = util.split(tostring(lon), ', ') if #lat_split == 3 and #lon_split == 3 then local lon_d, lat_d = toDecimal(lat_split[1], lat_split[2], lat_split[3], lon_split[1], lon_split[2], lon_split[3], lat_ref, lon_ref) local gmaps_link = string.format('https://maps.google.com/?q=%s,%s', lon_d, lat_d) exif_tags[#exif_tags+1] = gmaps_link end return exif_tags end local handleData = function(headers, data) local charset = guessCharset(headers, data) if(charset and charset ~= 'utf-8') then local cd, _ = iconv.new("utf-8", charset) if(cd) then data = cd:iconv(data) end end local head = data:match('<[hH][eE][aA][dD]>(.-)</[hH][eE][aA][dD]>') or data local title = head:match('<[tT][iI][tT][lL][eE][^/>]*>(.-)</[tT][iI][tT][lL][eE]>') if(title) then for _, pattern in ipairs(patterns) do title = title:gsub(pattern, '<snip />') end title = html2unicode(title) title = trim(title:gsub('%s%s+', ' ')) if(title ~= '<snip />' and #title > 0) then return limitOutput(title) end end -- No title found, return some possibly usefule info local content_type = headers['content-type'] local content_length = headers['content-length'] if content_length then content_length = math.floor(content_length/1024) else content_length = math.floor(#data/1024) -- will be limited to DL_LIMIT end local exif_tags = {} local googlevision_tags = {} if string.find(content_type, 'image/jp') then exif_tags = handleExif(data) if #data < 10485760 then -- max upload limit googlevision_tags = googlevision.annotateData(gvision_apikey, data) end end local message message = string.format('[%s] %s kB', content_type, content_length) if #exif_tags > 0 then message = message .. ', ' .. table.concat(exif_tags, ', ') end if #googlevision_tags > 0 then message = message .. ', ' .. table.concat(googlevision_tags, ', ') end return message end local handleOutput = function(metadata) metadata.num = metadata.num - 1 if(metadata.num ~= 0) then return end local output = {} for i=1, #metadata.queue do local lookup = metadata.queue[i] if(lookup.output) then table.insert(output, string.format('\002[%s]\002 %s', lookup.index, lookup.output)) end end if(#output > 0) then ivar2:Msg('privmsg', metadata.destination, metadata.source, table.concat(output, ' ')) end end local customHosts = {} local customPost = {} do local _PROXY = setmetatable( { DL_LIMIT = DL_LIMIT, ivar2 = ivar2, handleData = handleData, limitOutput = limitOutput, },{ __index = _G } ) local loadFile = function(kind, path, filename) local customFile, customError = loadfile(path .. filename) if(customFile) then setfenv(customFile, _PROXY) local success, message = pcall(customFile, ivar2) if(not success) then ivar2:Log('error', 'Unable to execute %s title handler %s: %s.', kind, filename:sub(1, -5), message) else ivar2:Log('info', 'Loading %s title handler: %s.', kind, filename:sub(1, -5)) return message end else ivar2:Log('error', 'Unable to load %s title handler %s: %s.', kind, filename:sub(1, -5), customError) end end -- Custom hosts do local path = 'modules/title/sites/' _PROXY.customHosts = customHosts for fn in lfs.dir(path) do if fn:match'%.lua$' then loadFile('custom', path, fn) end end _PROXY.customHosts = nil end -- Custom post processing do local path = 'modules/title/post/' for fn in lfs.dir(path) do if fn:match'%.lua$' then local func = loadFile('post', path, fn) if(func) then table.insert(customPost, func) end end end end end local fetchInformation = function(queue, lang) local info = uri_parse(queue.url) if(info) then info.url = queue.url if(info.path == '') then queue.url = queue.url .. '/' end local host = info.host:gsub('^www%.', '') for pattern, customHandler in next, customHosts do if(host:match(pattern) and customHandler(queue, info)) then -- Let the queue know it's being customhandled -- Can be used in postproc to make better decisions queue.customHandler = true return end end end simplehttp({ url = parseAJAX(queue.url), headers = { ['Accept-Language'] = lang }}, function(data, _, response) local message = handleData(response.headers, data) if(#queue.url > 80) then ivar2.x0(queue.url, function(short) if message then queue:done(string.format('Short URL: %s - %s', short, message)) else queue:done(string.format('Short URL: %s', short)) end end) else queue:done(message) end end, true, DL_LIMIT ) end local postProcess = function(source, destination, self, msg) for _, customHandler in next, customPost do customHandler(source, destination, self, msg) end end return { PRIVMSG = { function(self, source, destination, argument) -- We don't want to pick up URLs from commands. if(argument:match'^%p') then return end -- Handle CTCP ACTION if(argument:sub(1,1) == '\001' and argument:sub(-1) == '\001') then argument = argument:sub(9, -2) end local tmp = {} local tmpOrder = {} local index = 1 for split in argument:gmatch('%S+') do for i=1, #patterns do local _, count = split:gsub(patterns[i], function(url) -- URLs usually do not end with , Strip it. url = url:gsub(',$', '') if(url:sub(1,4) ~= 'http') then url = 'http://' .. url end self.event:Fire('url', self, source, destination, argument, url) url = smartEscape(url) if(not tmp[url]) then table.insert(tmpOrder, url) tmp[url] = index else tmp[url] = string.format('%s+%d', tmp[url], index) end end) if(count > 0) then index = index + 1 break end end end local lang = self:DestinationLocale(destination) if (lang:match('^nn')) then lang = 'nn, nb' elseif(lang:match('^nb')) then lang = 'nb, nn' else -- The default lang = 'en' end if(#tmpOrder > 0) then local output = { num = #tmpOrder, source = source, destination = destination, queue = {}, } for i=1, #tmpOrder do local url = tmpOrder[i] output.queue[i] = { index = tmp[url], url = url, done = function(myself, msg) myself.output = msg postProcess(source, destination, myself, argument) handleOutput(output) end, } fetchInformation(output.queue[i], lang) end end end, }, }
mit
flexiti/nodemcu-firmware
lua_modules/ds18b20/ds18b20.lua
54
3437
-------------------------------------------------------------------------------- -- DS18B20 one wire module for NODEMCU -- NODEMCU TEAM -- LICENCE: http://opensource.org/licenses/MIT -- Vowstar <vowstar@nodemcu.com> -- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values -------------------------------------------------------------------------------- -- Set module name as parameter of require local modname = ... local M = {} _G[modname] = M -------------------------------------------------------------------------------- -- Local used variables -------------------------------------------------------------------------------- -- DS18B20 dq pin local pin = nil -- DS18B20 default pin local defaultPin = 9 -------------------------------------------------------------------------------- -- Local used modules -------------------------------------------------------------------------------- -- Table module local table = table -- String module local string = string -- One wire module local ow = ow -- Timer module local tmr = tmr -- Limited to local environment setfenv(1,M) -------------------------------------------------------------------------------- -- Implementation -------------------------------------------------------------------------------- C = 0 F = 1 K = 2 function setup(dq) pin = dq if(pin == nil) then pin = defaultPin end ow.setup(pin) end function addrs() setup(pin) tbl = {} ow.reset_search(pin) repeat addr = ow.search(pin) if(addr ~= nil) then table.insert(tbl, addr) end tmr.wdclr() until (addr == nil) ow.reset_search(pin) return tbl end function readNumber(addr, unit) result = nil setup(pin) flag = false if(addr == nil) then ow.reset_search(pin) count = 0 repeat count = count + 1 addr = ow.search(pin) tmr.wdclr() until((addr ~= nil) or (count > 100)) ow.reset_search(pin) end if(addr == nil) then return result end crc = ow.crc8(string.sub(addr,1,7)) if (crc == addr:byte(8)) then if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then -- print("Device is a DS18S20 family device.") ow.reset(pin) ow.select(pin, addr) ow.write(pin, 0x44, 1) -- tmr.delay(1000000) present = ow.reset(pin) ow.select(pin, addr) ow.write(pin,0xBE,1) -- print("P="..present) data = nil data = string.char(ow.read(pin)) for i = 1, 8 do data = data .. string.char(ow.read(pin)) end -- print(data:byte(1,9)) crc = ow.crc8(string.sub(data,1,8)) -- print("CRC="..crc) if (crc == data:byte(9)) then t = (data:byte(1) + data:byte(2) * 256) if (t > 32767) then t = t - 65536 end if(unit == nil or unit == C) then t = t * 625 elseif(unit == F) then t = t * 1125 + 320000 elseif(unit == K) then t = t * 625 + 2731500 else return nil end t = t / 10000 -- print("Temperature="..t1.."."..t2.." Centigrade") -- result = t1.."."..t2 return t end tmr.wdclr() else -- print("Device family is not recognized.") end else -- print("CRC is not valid!") end return result end function read(addr, unit) t = readNumber(addr, unit) if (t == nil) then return nil else return t end end -- Return module table return M
mit
ifoxhz/iFox
scripts/lua/if_pkt_distro.lua
2
1241
-- -- (C) 2013-15 - ntop.org -- dirs = ntop.getDirs() package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path require "lua_utils" sendHTTPHeader('text/html; charset=iso-8859-1') interface.select(ifname) ifstats = aggregateInterfaceStats(interface.getStats()) type = _GET["distr"] if((type == nil) or (type == "size")) then what = ifstats["pktSizeDistribution"] end local pkt_distribution = { ['upTo64'] = '<= 64', ['upTo128'] = '64 <= 128', ['upTo256'] = '128 <= 256', ['upTo512'] = '256 <= 512', ['upTo1024'] = '512 <= 1024', ['upTo1518'] = '1024 <= 1518', ['upTo2500'] = '1518 <= 2500', ['upTo6500'] = '2500 <= 6500', ['upTo9000'] = '6500 <= 9000', ['above9000'] = '> 9000' } tot = 0 for key, value in pairs(what) do tot = tot + value end threshold = (tot * 5) / 100 print "[\n" num = 0 sum = 0 for key, value in pairs(what) do if(value > threshold) then if(num > 0) then print ",\n" end print("\t { \"label\": \"" .. pkt_distribution[key] .."\", \"value\": ".. value .." }") num = num + 1 sum = sum + value end end if(sum < tot) then print("\t, { \"label\": \"Other\", \"value\": ".. (tot-sum) .." }") end print "\n]"
gpl-3.0
litnimax/luci
applications/luci-firewall/luasrc/model/cbi/firewall/rule-details.lua
52
8016
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2010-2012 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- local sys = require "luci.sys" local utl = require "luci.util" local dsp = require "luci.dispatcher" local nxo = require "nixio" local ft = require "luci.tools.firewall" local nw = require "luci.model.network" local m, s, o, k, v arg[1] = arg[1] or "" m = Map("firewall", translate("Firewall - Traffic Rules"), translate("This page allows you to change advanced properties of the \ traffic rule entry, such as matched source and destination \ hosts.")) m.redirect = dsp.build_url("admin/network/firewall/rules") nw.init(m.uci) local rule_type = m.uci:get("firewall", arg[1]) if rule_type == "redirect" and m:get(arg[1], "target") ~= "SNAT" then rule_type = nil end if not rule_type then luci.http.redirect(m.redirect) return -- -- SNAT -- elseif rule_type == "redirect" then local name = m:get(arg[1], "name") or m:get(arg[1], "_name") if not name or #name == 0 then name = translate("(Unnamed SNAT)") else name = "SNAT %s" % name end m.title = "%s - %s" %{ translate("Firewall - Traffic Rules"), name } local wan_zone = nil m.uci:foreach("firewall", "zone", function(s) local n = s.network or s.name if n then local i for i in utl.imatch(n) do if i == "wan" then wan_zone = s.name return false end end end end) s = m:section(NamedSection, arg[1], "redirect", "") s.anonymous = true s.addremove = false ft.opt_enabled(s, Button) ft.opt_name(s, Value, translate("Name")) o = s:option(Value, "proto", translate("Protocol"), translate("You may specify multiple by selecting \"-- custom --\" and \ then entering protocols separated by space.")) o:value("all", "All protocols") o:value("tcp udp", "TCP+UDP") o:value("tcp", "TCP") o:value("udp", "UDP") o:value("icmp", "ICMP") function o.cfgvalue(...) local v = Value.cfgvalue(...) if not v or v == "tcpudp" then return "tcp udp" end return v end o = s:option(Value, "src", translate("Source zone")) o.nocreate = true o.default = "wan" o.template = "cbi/firewall_zonelist" o = s:option(Value, "src_ip", translate("Source IP address")) o.rmempty = true o.datatype = "neg(ipaddr)" o.placeholder = translate("any") luci.sys.net.ipv4_hints(function(ip, name) o:value(ip, "%s (%s)" %{ ip, name }) end) o = s:option(Value, "src_port", translate("Source port"), translate("Match incoming traffic originating from the given source \ port or port range on the client host.")) o.rmempty = true o.datatype = "neg(portrange)" o.placeholder = translate("any") o = s:option(Value, "dest", translate("Destination zone")) o.nocreate = true o.default = "lan" o.template = "cbi/firewall_zonelist" o = s:option(Value, "dest_ip", translate("Destination IP address")) o.datatype = "neg(ip4addr)" luci.sys.net.ipv4_hints(function(ip, name) o:value(ip, "%s (%s)" %{ ip, name }) end) o = s:option(Value, "dest_port", translate("Destination port"), translate("Match forwarded traffic to the given destination port or \ port range.")) o.rmempty = true o.placeholder = translate("any") o.datatype = "neg(portrange)" o = s:option(Value, "src_dip", translate("SNAT IP address"), translate("Rewrite matched traffic to the given address.")) o.rmempty = false o.datatype = "ip4addr" for k, v in ipairs(nw:get_interfaces()) do local a for k, a in ipairs(v:ipaddrs()) do o:value(a:host():string(), '%s (%s)' %{ a:host():string(), v:shortname() }) end end o = s:option(Value, "src_dport", translate("SNAT port"), translate("Rewrite matched traffic to the given source port. May be \ left empty to only rewrite the IP address.")) o.datatype = "portrange" o.rmempty = true o.placeholder = translate('Do not rewrite') s:option(Value, "extra", translate("Extra arguments"), translate("Passes additional arguments to iptables. Use with care!")) -- -- Rule -- else local name = m:get(arg[1], "name") or m:get(arg[1], "_name") if not name or #name == 0 then name = translate("(Unnamed Rule)") end m.title = "%s - %s" %{ translate("Firewall - Traffic Rules"), name } s = m:section(NamedSection, arg[1], "rule", "") s.anonymous = true s.addremove = false ft.opt_enabled(s, Button) ft.opt_name(s, Value, translate("Name")) o = s:option(ListValue, "family", translate("Restrict to address family")) o.rmempty = true o:value("", translate("IPv4 and IPv6")) o:value("ipv4", translate("IPv4 only")) o:value("ipv6", translate("IPv6 only")) o = s:option(Value, "proto", translate("Protocol")) o:value("all", translate("Any")) o:value("tcp udp", "TCP+UDP") o:value("tcp", "TCP") o:value("udp", "UDP") o:value("icmp", "ICMP") function o.cfgvalue(...) local v = Value.cfgvalue(...) if not v or v == "tcpudp" then return "tcp udp" end return v end o = s:option(DynamicList, "icmp_type", translate("Match ICMP type")) o:value("", "any") o:value("echo-reply") o:value("destination-unreachable") o:value("network-unreachable") o:value("host-unreachable") o:value("protocol-unreachable") o:value("port-unreachable") o:value("fragmentation-needed") o:value("source-route-failed") o:value("network-unknown") o:value("host-unknown") o:value("network-prohibited") o:value("host-prohibited") o:value("TOS-network-unreachable") o:value("TOS-host-unreachable") o:value("communication-prohibited") o:value("host-precedence-violation") o:value("precedence-cutoff") o:value("source-quench") o:value("redirect") o:value("network-redirect") o:value("host-redirect") o:value("TOS-network-redirect") o:value("TOS-host-redirect") o:value("echo-request") o:value("router-advertisement") o:value("router-solicitation") o:value("time-exceeded") o:value("ttl-zero-during-transit") o:value("ttl-zero-during-reassembly") o:value("parameter-problem") o:value("ip-header-bad") o:value("required-option-missing") o:value("timestamp-request") o:value("timestamp-reply") o:value("address-mask-request") o:value("address-mask-reply") o = s:option(Value, "src", translate("Source zone")) o.nocreate = true o.allowany = true o.default = "wan" o.template = "cbi/firewall_zonelist" o = s:option(Value, "src_mac", translate("Source MAC address")) o.datatype = "list(macaddr)" o.placeholder = translate("any") luci.sys.net.mac_hints(function(mac, name) o:value(mac, "%s (%s)" %{ mac, name }) end) o = s:option(Value, "src_ip", translate("Source address")) o.datatype = "neg(ipaddr)" o.placeholder = translate("any") luci.sys.net.ipv4_hints(function(ip, name) o:value(ip, "%s (%s)" %{ ip, name }) end) o = s:option(Value, "src_port", translate("Source port")) o.datatype = "list(neg(portrange))" o.placeholder = translate("any") o = s:option(Value, "dest", translate("Destination zone")) o.nocreate = true o.allowany = true o.allowlocal = true o.template = "cbi/firewall_zonelist" o = s:option(Value, "dest_ip", translate("Destination address")) o.datatype = "neg(ipaddr)" o.placeholder = translate("any") luci.sys.net.ipv4_hints(function(ip, name) o:value(ip, "%s (%s)" %{ ip, name }) end) o = s:option(Value, "dest_port", translate("Destination port")) o.datatype = "list(neg(portrange))" o.placeholder = translate("any") o = s:option(ListValue, "target", translate("Action")) o.default = "ACCEPT" o:value("DROP", translate("drop")) o:value("ACCEPT", translate("accept")) o:value("REJECT", translate("reject")) o:value("NOTRACK", translate("don't track")) s:option(Value, "extra", translate("Extra arguments"), translate("Passes additional arguments to iptables. Use with care!")) end return m
apache-2.0
abasshacker/abbas3
plugins/rae.lua
616
1312
do function getDulcinea( text ) -- Powered by https://github.com/javierhonduco/dulcinea local api = "http://dulcinea.herokuapp.com/api/?query=" local query_url = api..text local b, code = http.request(query_url) if code ~= 200 then return "Error: HTTP Connection" end dulcinea = json:decode(b) if dulcinea.status == "error" then return "Error: " .. dulcinea.message end while dulcinea.type == "multiple" do text = dulcinea.response[1].id b = http.request(api..text) dulcinea = json:decode(b) end local text = "" local responses = #dulcinea.response if responses == 0 then return "Error: 404 word not found" end if (responses > 5) then responses = 5 end for i = 1, responses, 1 do text = text .. dulcinea.response[i].word .. "\n" local meanings = #dulcinea.response[i].meanings if (meanings > 5) then meanings = 5 end for j = 1, meanings, 1 do local meaning = dulcinea.response[i].meanings[j].meaning text = text .. meaning .. "\n\n" end end return text end function run(msg, matches) return getDulcinea(matches[1]) end return { description = "Spanish dictionary", usage = "!rae [word]: Search that word in Spanish dictionary.", patterns = {"^!rae (.*)$"}, run = run } end
gpl-2.0
tst2005/luacheck
spec/parser_spec.lua
3
46935
local parser = require "luacheck.parser" local function strip_locations(ast) ast.location = nil ast.end_location = nil ast.end_column = nil ast.equals_location = nil ast.first_token = nil for i=1, #ast do if type(ast[i]) == "table" then strip_locations(ast[i]) end end end local function get_ast(src) local ast = parser(src) assert.is_table(ast) strip_locations(ast) return ast end local function get_node(src) return get_ast(src)[1] end local function get_expr(src) return get_node("return " .. src)[1] end local function get_comments(src) return (select(2, parser(src))) end local function get_code_lines(src) return select(3, parser(src)) end local function get_error(src) local ok, err = pcall(parser, src) assert.is_false(ok) return err end describe("parser", function() it("parses empty source correctly", function() assert.same({}, get_ast(" ")) end) it("does not allow extra ending keywords", function() assert.same({line = 1, column = 1, end_column = 3, msg = "expected <eof> near 'end'"}, get_error("end")) end) it("parses return statement correctly", function() assert.same({tag = "Return"}, get_node("return")) assert.same({tag = "Return", {tag = "Number", "1"} }, get_node("return 1")) assert.same({tag = "Return", {tag = "Number", "1"}, {tag = "String", "foo"} }, get_node("return 1, 'foo'")) assert.same({line = 1, column = 10, end_column = 10, msg = "unexpected symbol near <eof>"}, get_error("return 1,")) end) it("parses labels correctly", function() assert.same({tag = "Label", "fail"}, get_node("::fail::")) assert.same({tag = "Label", "fail"}, get_node("::\nfail\n::")) assert.same({line = 1, column = 3, end_column = 4, msg = "expected identifier near '::'"}, get_error("::::")) assert.same({line = 1, column = 3, end_column = 3, msg = "expected identifier near '1'"}, get_error("::1::")) end) it("parses goto correctly", function() assert.same({tag = "Goto", "fail"}, get_node("goto fail")) assert.same({line = 1, column = 5, end_column = 5, msg = "expected identifier near <eof>"}, get_error("goto")) assert.same({line = 1, column = 9, end_column = 9, msg = "unexpected symbol near ','"}, get_error("goto foo, bar")) end) it("parses break correctly", function() assert.same({tag = "Break"}, get_node("break")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected '=' near <eof>"}, get_error("break fail")) end) it("parses do end correctly", function() assert.same({tag = "Do"}, get_node("do end")) assert.same({line = 1, column = 3, end_column = 3, msg = "expected 'end' near <eof>"}, get_error("do")) assert.same({line = 1, column = 4, end_column = 8, msg = "expected 'end' near 'until'"}, get_error("do until false")) end) it("parses while do end correctly", function() assert.same({tag = "While", {tag = "True"}, {} }, get_node("while true do end")) assert.same({line = 1, column = 6, end_column = 6, msg = "unexpected symbol near <eof>"}, get_error("while")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected 'do' near <eof>"}, get_error("while true")) assert.same({line = 1, column = 14, end_column = 14, msg = "expected 'end' near <eof>"}, get_error("while true do")) assert.same({line = 1, column = 7, end_column = 8, msg = "unexpected symbol near 'do'"}, get_error("while do end")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected 'do' near ','"}, get_error("while true, false do end")) end) it("parses repeat until correctly", function() assert.same({tag = "Repeat", {}, {tag = "True"} }, get_node("repeat until true")) assert.same({line = 1, column = 7, end_column = 7, msg = "expected 'until' near <eof>"}, get_error("repeat")) assert.same({line = 1, column = 13, end_column = 13, msg = "unexpected symbol near <eof>"}, get_error("repeat until")) assert.same({line = 1, column = 18, end_column = 18, msg = "unexpected symbol near ','"}, get_error("repeat until true, false")) end) describe("when parsing if", function() it("parses if then end correctly", function() assert.same({tag = "If", {tag = "True"}, {} }, get_node("if true then end")) assert.same({line = 1, column = 3, end_column = 3, msg = "unexpected symbol near <eof>"}, get_error("if")) assert.same({line = 1, column = 8, end_column = 8, msg = "expected 'then' near <eof>"}, get_error("if true")) assert.same({line = 1, column = 13, end_column = 13, msg = "expected 'end' near <eof>"}, get_error("if true then")) assert.same({line = 1, column = 4, end_column = 7, msg = "unexpected symbol near 'then'"}, get_error("if then end")) assert.same({line = 1, column = 8, end_column = 8, msg = "expected 'then' near ','"}, get_error("if true, false then end")) end) it("parses if then else end correctly", function() assert.same({tag = "If", {tag = "True"}, {}, {} }, get_node("if true then else end")) assert.same({line = 1, column = 18, end_column = 18, msg = "expected 'end' near <eof>"}, get_error("if true then else")) assert.same({line = 1, column = 19, end_column = 22, msg = "expected 'end' near 'else'"}, get_error("if true then else else end")) end) it("parses if then elseif then end correctly", function() assert.same({tag = "If", {tag = "True"}, {}, {tag = "False"}, {} }, get_node("if true then elseif false then end")) assert.same({line = 1, column = 21, end_column = 23, msg = "unexpected symbol near 'end'"}, get_error("if true then elseif end")) assert.same({line = 1, column = 21, end_column = 24, msg = "unexpected symbol near 'then'"}, get_error("if true then elseif then end")) end) it("parses if then elseif then else end correctly", function() assert.same({tag = "If", {tag = "True"}, {}, {tag = "False"}, {}, {} }, get_node("if true then elseif false then else end")) assert.same({line = 1, column = 36, end_column = 36, msg = "expected 'end' near <eof>"}, get_error("if true then elseif false then else")) end) end) describe("when parsing for", function() it("parses fornum correctly", function() assert.same({tag = "Fornum", {tag = "Id", "i"}, {tag = "Number", "1"}, {tag = "Op", "len", {tag = "Id", "t"}}, {} }, get_node("for i=1, #t do end")) assert.same({line = 1, column = 4, end_column = 4, msg = "expected identifier near <eof>"}, get_error("for")) assert.same({line = 1, column = 6, end_column = 6, msg = "expected '=', ',' or 'in' near <eof>"}, get_error("for i")) assert.same({line = 1, column = 7, end_column = 8, msg = "expected '=', ',' or 'in' near '~='"}, get_error("for i ~= 2")) assert.same({line = 1, column = 11, end_column = 12, msg = "expected ',' near 'do'"}, get_error("for i = 2 do end")) assert.same({line = 1, column = 15, end_column = 15, msg = "expected 'end' near <eof>"}, get_error("for i=1, #t do")) assert.same({line = 1, column = 5, end_column = 5, msg = "expected identifier near '('"}, get_error("for (i)=1, #t do end")) assert.same({line = 1, column = 5, end_column = 5, msg = "expected identifier near '3'"}, get_error("for 3=1, #t do end")) end) it("parses fornum with step correctly", function() assert.same({tag = "Fornum", {tag = "Id", "i"}, {tag = "Number", "1"}, {tag = "Op", "len", {tag = "Id", "t"}}, {tag = "Number", "2"}, {} }, get_node("for i=1, #t, 2 do end")) assert.same({line = 1, column = 15, end_column = 15, msg = "expected 'do' near ','"}, get_error("for i=1, #t, 2, 3 do")) end) it("parses forin correctly", function() assert.same({tag = "Forin", { {tag = "Id", "i"} }, { {tag = "Id", "t"} }, {} }, get_node("for i in t do end")) assert.same({tag = "Forin", { {tag = "Id", "i"}, {tag = "Id", "j"} }, { {tag = "Id", "t"}, {tag = "String", "foo"} }, {} }, get_node("for i, j in t, 'foo' do end")) assert.same({line = 1, column = 5, end_column = 6, msg = "expected identifier near 'in'"}, get_error("for in foo do end")) assert.same({line = 1, column = 10, end_column = 11, msg = "unexpected symbol near 'do'"}, get_error("for i in do end")) end) end) describe("when parsing functions", function() it("parses simple function correctly", function() assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Function", {}, {}} } }, get_node("function a() end")) assert.same({line = 1, column = 9, end_column = 9, msg = "expected identifier near <eof>"}, get_error("function")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected '(' near <eof>"}, get_error("function a")) assert.same({line = 1, column = 12, end_column = 12, msg = "expected argument near <eof>"}, get_error("function a(")) assert.same({line = 1, column = 13, end_column = 13, msg = "expected 'end' near <eof>"}, get_error("function a()")) assert.same({line = 1, column = 10, end_column = 10, msg = "expected identifier near '('"}, get_error("function (a)()")) assert.same({line = 1, column = 9, end_column = 9, msg = "expected identifier near '('"}, get_error("function() end")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected '(' near 'a'"}, get_error("(function a() end)")) assert.same({line = 1, column = 18, end_column = 18, msg = "unexpected symbol near ')'"}, get_error("function a() end()")) end) it("parses simple function with arguments correctly", function() assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Function", {{tag = "Id", "b"}}, {}} } }, get_node("function a(b) end")) assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Function", {{tag = "Id", "b"}, {tag = "Id", "c"}}, {}} } }, get_node("function a(b, c) end")) assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Function", {{tag = "Id", "b"}, {tag = "Dots", "..."}}, {}} } }, get_node("function a(b, ...) end")) assert.same({line = 1, column = 15, end_column = 15, msg = "expected argument near ')'"}, get_error("function a(b, ) end")) assert.same({line = 1, column = 13, end_column = 13, msg = "expected ')' near '.'"}, get_error("function a(b.c) end")) assert.same({line = 1, column = 12, end_column = 12, msg = "expected argument near '('"}, get_error("function a((b)) end")) assert.same({line = 1, column = 15, end_column = 15, msg = "expected ')' near ','"}, get_error("function a(..., ...) end")) end) it("parses field function correctly", function() assert.same({tag = "Set", { {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}} }, { {tag = "Function", {}, {}} } }, get_node("function a.b() end")) assert.same({tag = "Set", { {tag = "Index", {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}}, {tag = "String", "c"} } }, { {tag = "Function", {}, {}} } }, get_node("function a.b.c() end")) assert.same({line = 1, column = 11, end_column = 11, msg = "expected '(' near '['"}, get_error("function a[b]() end")) assert.same({line = 1, column = 12, end_column = 12, msg = "expected identifier near '('"}, get_error("function a.() end")) end) it("parses method function correctly", function() assert.same({tag = "Set", { {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}} }, { {tag = "Function", {{tag = "Id", "self", implicit = true}}, {}} } }, get_node("function a:b() end")) assert.same({tag = "Set", { {tag = "Index", {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}}, {tag = "String", "c"} } }, { {tag = "Function", {{tag = "Id", "self", implicit = true}}, {}} } }, get_node("function a.b:c() end")) assert.same({line = 1, column = 13, end_column = 13, msg = "expected '(' near '.'"}, get_error("function a:b.c() end")) end) end) describe("when parsing local declarations", function() it("parses simple local declaration correctly", function() assert.same({tag = "Local", { {tag = "Id", "a"} } }, get_node("local a")) assert.same({tag = "Local", { {tag = "Id", "a"}, {tag = "Id", "b"} } }, get_node("local a, b")) assert.same({line = 1, column = 6, end_column = 6, msg = "expected identifier near <eof>"}, get_error("local")) assert.same({line = 1, column = 9, end_column = 9, msg = "expected identifier near <eof>"}, get_error("local a,")) assert.same({line = 1, column = 8, end_column = 8, msg = "unexpected symbol near '.'"}, get_error("local a.b")) assert.same({line = 1, column = 8, end_column = 8, msg = "unexpected symbol near '['"}, get_error("local a[b]")) assert.same({line = 1, column = 7, end_column = 7, msg = "expected identifier near '('"}, get_error("local (a)")) end) it("parses local declaration with assignment correctly", function() assert.same({tag = "Local", { {tag = "Id", "a"} }, { {tag = "Id", "b"} } }, get_node("local a = b")) assert.same({tag = "Local", { {tag = "Id", "a"}, {tag = "Id", "b"} }, { {tag = "Id", "c"}, {tag = "Id", "d"} } }, get_node("local a, b = c, d")) assert.same({line = 1, column = 11, end_column = 11, msg = "unexpected symbol near <eof>"}, get_error("local a = ")) assert.same({line = 1, column = 13, end_column = 13, msg = "unexpected symbol near <eof>"}, get_error("local a = b,")) assert.same({line = 1, column = 8, end_column = 8, msg = "unexpected symbol near '.'"}, get_error("local a.b = c")) assert.same({line = 1, column = 8, end_column = 8, msg = "unexpected symbol near '['"}, get_error("local a[b] = c")) assert.same({line = 1, column = 10, end_column = 10, msg = "expected identifier near '('"}, get_error("local a, (b) = c")) end) it("parses local function declaration correctly", function() assert.same({tag = "Localrec", {tag = "Id", "a"}, {tag = "Function", {}, {}} }, get_node("local function a() end")) assert.same({line = 1, column = 15, end_column = 15, msg = "expected identifier near <eof>"}, get_error("local function")) assert.same({line = 1, column = 17, end_column = 17, msg = "expected '(' near '.'"}, get_error("local function a.b() end")) end) end) describe("when parsing assignments", function() it("parses single target assignment correctly", function() assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Id", "b"} } }, get_node("a = b")) assert.same({tag = "Set", { {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}} }, { {tag = "Id", "c"} } }, get_node("a.b = c")) assert.same({tag = "Set", { {tag = "Index", {tag = "Index", {tag = "Id", "a"}, {tag = "String", "b"}}, {tag = "String", "c"} } }, { {tag = "Id", "d"} } }, get_node("a.b.c = d")) assert.same({tag = "Set", { {tag = "Index", {tag = "Invoke", {tag = "Call", {tag = "Id", "f"}}, {tag = "String", "g"} }, {tag = "Number", "9"} } }, { {tag = "Id", "d"} } }, get_node("(f():g())[9] = d")) assert.same({line = 1, column = 2, end_column = 2, msg = "expected '=' near <eof>"}, get_error("a")) assert.same({line = 1, column = 5, end_column = 5, msg = "unexpected symbol near <eof>"}, get_error("a = ")) assert.same({line = 1, column = 5, end_column = 5, msg = "unexpected symbol near '='"}, get_error("a() = b")) assert.same({line = 1, column = 5, end_column = 5, msg = "syntax error near '='"}, get_error("(a) = b")) assert.same({line = 1, column = 1, end_column = 1, msg = "unexpected symbol near '1'"}, get_error("1 = b")) end) it("parses multi assignment correctly", function() assert.same({tag = "Set", { {tag = "Id", "a"}, {tag = "Id", "b"} }, { {tag = "Id", "c"}, {tag = "Id", "d"} } }, get_node("a, b = c, d")) assert.same({line = 1, column = 5, end_column = 5, msg = "expected '=' near <eof>"}, get_error("a, b")) assert.same({line = 1, column = 4, end_column = 4, msg = "unexpected symbol near '='"}, get_error("a, = b")) assert.same({line = 1, column = 8, end_column = 8, msg = "unexpected symbol near <eof>"}, get_error("a, b = ")) assert.same({line = 1, column = 10, end_column = 10, msg = "unexpected symbol near <eof>"}, get_error("a, b = c,")) assert.same({line = 1, column = 8, end_column = 8, msg = "syntax error near '='"}, get_error("a, b() = c")) assert.same({line = 1, column = 8, end_column = 8, msg = "syntax error near '='"}, get_error("a, (b) = c")) end) end) describe("when parsing expression statements", function() it("parses calls correctly", function() assert.same({tag = "Call", {tag = "Id", "a"} }, get_node("a()")) assert.same({tag = "Call", {tag = "Id", "a"}, {tag = "String", "b"} }, get_node("a'b'")) assert.same({tag = "Call", {tag = "Id", "a"}, {tag = "Table"} }, get_node("a{}")) assert.same({tag = "Call", {tag = "Id", "a"}, {tag = "Id", "b"} }, get_node("a(b)")) assert.same({tag = "Call", {tag = "Id", "a"}, {tag = "Id", "b"}, {tag = "Id", "c"} }, get_node("a(b, c)")) assert.same({tag = "Call", {tag = "Id", "a"}, {tag = "Id", "b"} }, get_node("(a)(b)")) assert.same({tag = "Call", {tag = "Call", {tag = "Id", "a"}, {tag = "Id", "b"} } }, get_node("(a)(b)()")) assert.same({line = 1, column = 2, end_column = 2, msg = "unexpected symbol near ')'"}, get_error("()()")) assert.same({line = 1, column = 3, end_column = 3, msg = "unexpected symbol near <eof>"}, get_error("a(")) assert.same({line = 1, column = 1, end_column = 1, msg = "unexpected symbol near '1'"}, get_error("1()")) assert.same({line = 1, column = 1, end_column = 5, msg = "unexpected symbol near ''foo''"}, get_error("'foo'()")) assert.same({line = 1, column = 9, end_column = 9, msg = "expected identifier near '('"}, get_error("function() end ()")) end) it("parses method calls correctly", function() assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"} }, get_node("a:b()")) assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"}, {tag = "String", "c"} }, get_node("a:b'c'")) assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"}, {tag = "Table"} }, get_node("a:b{}")) assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"}, {tag = "Id", "c"} }, get_node("a:b(c)")) assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"}, {tag = "Id", "c"}, {tag = "Id", "d"} }, get_node("a:b(c, d)")) assert.same({tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"}, {tag = "Id", "c"} }, get_node("(a):b(c)")) assert.same({tag = "Invoke", {tag = "Invoke", {tag = "Id", "a"}, {tag = "String", "b"} }, {tag = "String", "c"} }, get_node("a:b():c()")) assert.same({line = 1, column = 1, end_column = 1, msg = "unexpected symbol near '1'"}, get_error("1:b()")) assert.same({line = 1, column = 1, end_column = 2, msg = "unexpected symbol near ''''"}, get_error("'':a()")) assert.same({line = 1, column = 9, end_column = 9, msg = "expected identifier near '('"}, get_error("function()end:b()")) assert.same({line = 1, column = 4, end_column = 4, msg = "expected method arguments near ':'"}, get_error("a:b:c()")) assert.same({line = 1, column = 3, end_column = 3, msg = "expected identifier near <eof>"}, get_error("a:")) end) end) describe("when parsing expressions", function() it("parses singleton expressions correctly", function() assert.same({tag = "Nil"}, get_expr("nil")) assert.same({tag = "True"}, get_expr("true")) assert.same({tag = "False"}, get_expr("false")) assert.same({tag = "Number", "1"}, get_expr("1")) assert.same({tag = "String", "1"}, get_expr("'1'")) assert.same({tag = "Table"}, get_expr("{}")) assert.same({tag = "Function", {}, {}}, get_expr("function() end")) assert.same({tag = "Dots", "..."}, get_expr("...")) end) it("parses table constructors correctly", function() assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Id", "b"}, {tag = "Id", "c"} }, get_expr("{a, b, c}")) assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Pair", {tag = "String", "b"}, {tag = "Id", "c"}}, {tag = "Id", "d"} }, get_expr("{a, b = c, d}")) assert.same({tag = "Table", {tag = "String", "a"}, {tag = "Pair", {tag = "Id", "b"}, {tag = "Id", "c"}}, {tag = "Id", "d"} }, get_expr("{[[a]], [b] = c, d}")) assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Id", "b"}, {tag = "Id", "c"} }, get_expr("{a; b, c}")) assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Id", "b"}, {tag = "Id", "c"} }, get_expr("{a; b, c,}")) assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Id", "b"}, {tag = "Id", "c"} }, get_expr("{a; b, c;}")) assert.same({line = 1, column = 9, end_column = 9, msg = "unexpected symbol near ';'"}, get_error("return {;}")) assert.same({line = 1, column = 9, end_column = 9, msg = "unexpected symbol near <eof>"}, get_error("return {")) assert.same({line = 1, column = 11, end_column = 11, msg = "unexpected symbol near ','"}, get_error("return {a,,}")) assert.same({line = 1, column = 13, end_column = 13, msg = "unexpected symbol near <eof>"}, get_error("return {a = ")) end) it("wraps last element in table constructors in parens when needed", function() assert.same({tag = "Table", {tag = "Id", "a"}, {tag = "Paren", {tag = "Call", {tag = "Id", "f"} } } }, get_expr("{a, (f())}")) assert.same({tag = "Table", {tag = "Call", {tag = "Id", "f"} }, {tag = "Id", "a"} }, get_expr("{(f()), a}")) assert.same({tag = "Table", {tag = "Pair", {tag = "String", "a"}, {tag = "Call", {tag = "Id", "f"} } } }, get_expr("{a = (f())}")) assert.same({tag = "Table", {tag = "Call", {tag = "Id", "f"} }, {tag = "Pair", {tag = "String", "a"}, {tag = "Id", "b"} } }, get_expr("{(f()), a = b}")) end) it("parses simple expressions correctly", function() assert.same({tag = "Op", "unm", {tag = "Number", "1"} }, get_expr("-1")) assert.same({tag = "Op", "add", {tag = "Op", "add", {tag = "Number", "1"}, {tag = "Number", "2"} }, {tag = "Number", "3"} }, get_expr("1+2+3")) assert.same({tag = "Op", "pow", {tag = "Number", "1"}, {tag = "Op", "pow", {tag = "Number", "2"}, {tag = "Number", "3"} } }, get_expr("1^2^3")) assert.same({tag = "Op", "concat", {tag = "String", "1"}, {tag = "Op", "concat", {tag = "String", "2"}, {tag = "String", "3"} } }, get_expr("'1'..'2'..'3'")) end) it("handles operator precedence correctly", function() assert.same({tag = "Op", "add", {tag = "Op", "unm", {tag = "Number", "1"} }, {tag = "Op", "mul", {tag = "Number", "2"}, {tag = "Op", "pow", {tag = "Number", "3"}, {tag = "Number", "4"} } } }, get_expr("-1+2*3^4")) assert.same({tag = "Op", "bor", {tag = "Op", "bor", {tag = "Op", "band", {tag = "Op", "shr", {tag = "Number", "1"}, {tag = "Number", "2"} }, {tag = "Op", "shl", {tag = "Number", "3"}, {tag = "Number", "4"} } }, {tag = "Op", "bxor", {tag = "Number", "5"}, {tag = "Number", "6"} } }, {tag = "Op", "bnot", {tag = "Number", "7"} } }, get_expr("1 >> 2 & 3 << 4 | 5 ~ 6 | ~7")) assert.same({tag = "Op", "or", {tag = "Op", "and", {tag = "Op", "eq", {tag = "Id", "a"}, {tag = "Id", "b"} }, {tag = "Op", "eq", {tag = "Id", "c"}, {tag = "Id", "d"} } }, {tag = "Op", "ne", {tag = "Id", "e"}, {tag = "Id", "f"} } }, get_expr("a == b and c == d or e ~= f")) end) it("wraps last expression in a list in parens when needed", function() assert.same({tag = "Return", {tag = "Dots", "..."}, {tag = "Paren", {tag = "Dots", "..."}} }, get_node("return (...), (...)")) assert.same({tag = "Return", {tag = "Dots", "..."}, {tag = "Dots", "..."} }, get_node("return (...), ...")) assert.same({tag = "Return", {tag = "True"}, {tag = "False"} }, get_node("return (true), (false)")) assert.same({tag = "Return", {tag = "Call", {tag = "Id", "f"} }, {tag = "Paren", {tag = "Call", {tag = "Id", "g"} } } }, get_node("return (f()), (g())")) assert.same({tag = "Return", {tag = "Invoke", {tag = "Id", "f"}, {tag = "String", "n"} }, {tag = "Paren", {tag = "Invoke", {tag = "Id", "g"}, {tag = "String", "m"} } } }, get_node("return (f:n()), (g:m())")) end) end) describe("when parsing multiple statements", function() it("considers semicolons and comments no-op statements", function() assert.same({tag = "Set", { {tag = "Id", "a"} }, { {tag = "Id", "b"} } }, get_node(";;;a = b;--[[]];--;")) end) it("does not allow statements after return", function() assert.same({line = 1, column = 8, end_column = 12, msg = "unexpected symbol near 'break'"}, get_error("return break")) assert.same({line = 1, column = 9, end_column = 13, msg = "expected end of block near 'break'"}, get_error("return; break")) assert.same({line = 1, column = 8, end_column = 8, msg = "expected end of block near ';'"}, get_error("return;;")) assert.same({line = 1, column = 10, end_column = 14, msg = "expected end of block near 'break'"}, get_error("return 1 break")) assert.same({line = 1, column = 11, end_column = 15, msg = "expected end of block near 'break'"}, get_error("return 1; break")) assert.same({line = 1, column = 13, end_column = 17, msg = "expected end of block near 'break'"}, get_error("return 1, 2 break")) assert.same({line = 1, column = 14, end_column = 18, msg = "expected end of block near 'break'"}, get_error("return 1, 2; break")) end) it("parses nested statements correctly", function() assert.same({ {tag = "Localrec", {tag = "Id", "f"}, {tag = "Function", {}, { {tag = "While", {tag = "True"}, { {tag = "If", {tag = "Nil"}, { {tag = "Call", {tag = "Id", "f"} }, {tag = "Return"} }, {tag = "False"}, { {tag = "Call", {tag = "Id", "g"} }, {tag = "Break"} }, { {tag = "Call", {tag = "Id", "h"} }, {tag = "Repeat", { {tag = "Goto", "fail"} }, {tag = "Id", "get_forked"} } } } } }, {tag = "Label", "fail"} }} }, {tag = "Do", {tag = "Fornum", {tag = "Id", "i"}, {tag = "Number", "1"}, {tag = "Number", "2"}, { {tag = "Call", {tag = "Id", "nothing"} } } }, {tag = "Forin", { {tag = "Id", "k"}, {tag = "Id", "v"} }, { {tag = "Call", {tag = "Id", "pairs"} } }, { {tag = "Call", {tag = "Id", "print"}, {tag = "String", "bar"} }, {tag = "Call", {tag = "Id", "assert"}, {tag = "Number", "42"} } } }, {tag = "Return"} }, }, get_ast([[ local function f() while true do if nil then f() return elseif false then g() break else h() repeat goto fail until get_forked end end ::fail:: end do for i=1, 2 do nothing() end for k, v in pairs() do print("bar") assert(42) end return end ]])) end) end) it("provides correct location info", function() assert.same({ {tag = "Localrec", location = {line = 1, column = 1, offset = 1}, first_token = "local", {tag = "Id", "foo", location = {line = 1, column = 16, offset = 16}}, {tag = "Function", location = {line = 1, column = 7, offset = 7}, end_location = {line = 4, column = 1, offset = 78}, { {tag = "Id", "a", location = {line = 1, column = 20, offset = 20}}, {tag = "Id", "b", location = {line = 1, column = 23, offset = 23}}, {tag = "Id", "c", location = {line = 1, column = 26, offset = 26}}, {tag = "Dots", "...", location = {line = 1, column = 29, offset = 29}} }, { {tag = "Local", location = {line = 2, column = 4, offset = 37}, first_token = "local", equals_location = {line = 2, column = 12, offset = 45}, { {tag = "Id", "d", location = {line = 2, column = 10, offset = 43}} }, { {tag = "Op", "mul", location = {line = 2, column = 15, offset = 48}, {tag = "Op", "add", location = {line = 2, column = 15, offset = 48}, {tag = "Id", "a", location = {line = 2, column = 15, offset = 48}}, {tag = "Id", "b", location = {line = 2, column = 19, offset = 52}} }, {tag = "Id", "c", location = {line = 2, column = 24, offset = 57}} } } }, {tag = "Return", location = {line = 3, column = 4, offset = 62}, first_token = "return", {tag = "Id", "d", location = {line = 3, column = 11, offset = 69}}, {tag = "Paren", location = {line = 3, column = 15, offset = 73}, {tag = "Dots", "...", location = {line = 3, column = 15, offset = 73}} } } } } }, {tag = "Set", location = {line = 6, column = 1, offset = 83}, first_token = "function", { {tag = "Index", location = {line = 6, column = 10, offset = 92}, {tag = "Id", "t", location = {line = 6, column = 10, offset = 92}}, {tag = "String", "bar", location = {line = 6, column = 12, offset = 94}} } }, { {tag = "Function", location = {line = 6, column = 1, offset = 83}, end_location = {line = 10, column = 1, offset = 142}, { {tag = "Id", "self", implicit = true, location = {line = 6, column = 11, offset = 93}}, {tag = "Id", "arg", location = {line = 6, column = 16, offset = 98}} }, { {tag = "If", location = {line = 7, column = 4, offset = 106}, first_token = "if", {tag = "Id", "arg", location = {line = 7, column = 7, offset = 109}, first_token = "arg"}, {location = {line = 7, column = 11, offset = 113}, -- Branch location. {tag = "Call", location = {line = 8, column = 7, offset = 124}, first_token = "print", {tag = "Id", "print", location = {line = 8, column = 7, offset = 124}}, {tag = "Id", "arg", location = {line = 8, column = 13, offset = 130}} } } } } } } } }, (parser([[ local function foo(a, b, c, ...) local d = (a + b) * c return d, (...) end function t:bar(arg) if arg then print(arg) end end ]]))) end) it("provides correct location info for labels", function() assert.same({ {tag = "Label", "foo", location = {line = 1, column = 1, offset = 1}, end_column = 7, first_token = "::"}, {tag = "Label", "bar", location = {line = 2, column = 1, offset = 9}, end_column = 6, first_token = "::"}, {tag = "Label", "baz", location = {line = 3, column = 3, offset = 18}, end_column = 4, first_token = "::"} }, (parser([[ ::foo:: :: bar :::: baz:: ]]))) end) it("provides correct location info for statements starting with expressions", function() assert.same({ {tag = "Call", location = {line = 1, column = 1, offset = 1}, first_token = "a", {tag = "Id", "a", location = {line = 1, column = 1, offset = 1}} }, {tag = "Call", location = {line = 2, column = 1, offset = 6}, first_token = "(", {tag = "Id", "b", location = {line = 2, column = 2, offset = 7}} }, {tag = "Set", location = {line = 3, column = 1, offset = 13}, first_token = "(", equals_location = {line = 3, column = 12, offset = 24}, { {tag = "Index", location = {line = 3, column = 3, offset = 15}, {tag = "Index", location = {line = 3, column = 3, offset = 15}, {tag = "Id", "c", location = {line = 3, column = 3, offset = 15}}, {tag = "String", "d", location = {line = 3, column = 6, offset = 18}} }, {tag = "Number", "3", location = {line = 3, column = 9, offset = 21}} } }, { {tag = "Number", "2", location = {line = 3, column = 14, offset = 26}} } } }, (parser([[ a(); (b)(); ((c).d)[3] = 2 ]]))) end) it("provides correct error location info", function() assert.same({line = 8, column = 15, end_column = 15, msg = "expected '=' near ')'"}, get_error([[ local function foo(a, b, c, ...) local d = (a + b) * c return d, (...) end function t:bar(arg) if arg then printarg) end end ]])) end) describe("providing misc information", function() it("provides comments correctly", function() assert.same({ {contents = " ignore something", location = {line = 1, column = 1, offset = 1}, end_column = 19}, {contents = " comments", location = {line = 2, column = 13, offset = 33}, end_column = 23}, {contents = "long comment", location = {line = 3, column = 13, offset = 57}, end_column = 17} }, get_comments([[ -- ignore something foo = bar() -- comments return true --[=[ long comment]=] ]])) end) it("provides lines with code correctly", function() -- EOS is considered "code" (which does not matter w.r.t inline options). assert.same({nil, true, true, true, true, true, nil, nil, true, true, true}, get_code_lines([[ -- nothing here local foo = 2 + 3 + { --[=[empty]=] } ::bar:: ]])) end) end) end)
mit
nobie/sesame_fw
feeds/luci/contrib/luadoc/dist/usr/lib/lua/luadoc/taglet/standard/tags.lua
93
5221
------------------------------------------------------------------------------- -- Handlers for several tags -- @release $Id: tags.lua,v 1.8 2007/09/05 12:39:09 tomas Exp $ ------------------------------------------------------------------------------- local luadoc = require "luadoc" local util = require "luadoc.util" local string = require "string" local table = require "table" local assert, type, tostring = assert, type, tostring module "luadoc.taglet.standard.tags" ------------------------------------------------------------------------------- local function author (tag, block, text) block[tag] = block[tag] or {} if not text then luadoc.logger:warn("author `name' not defined [["..text.."]]: skipping") return end table.insert (block[tag], text) end ------------------------------------------------------------------------------- -- Set the class of a comment block. Classes can be "module", "function", -- "table". The first two classes are automatic, extracted from the source code local function class (tag, block, text) block[tag] = text end ------------------------------------------------------------------------------- local function cstyle (tag, block, text) block[tag] = text end ------------------------------------------------------------------------------- local function copyright (tag, block, text) block[tag] = text end ------------------------------------------------------------------------------- local function description (tag, block, text) block[tag] = text end ------------------------------------------------------------------------------- local function field (tag, block, text) if block["class"] ~= "table" then luadoc.logger:warn("documenting `field' for block that is not a `table'") end block[tag] = block[tag] or {} local _, _, name, desc = string.find(text, "^([_%w%.]+)%s+(.*)") assert(name, "field name not defined") table.insert(block[tag], name) block[tag][name] = desc end ------------------------------------------------------------------------------- -- Set the name of the comment block. If the block already has a name, issue -- an error and do not change the previous value local function name (tag, block, text) if block[tag] and block[tag] ~= text then luadoc.logger:error(string.format("block name conflict: `%s' -> `%s'", block[tag], text)) end block[tag] = text end ------------------------------------------------------------------------------- -- Processes a parameter documentation. -- @param tag String with the name of the tag (it must be "param" always). -- @param block Table with previous information about the block. -- @param text String with the current line beeing processed. local function param (tag, block, text) block[tag] = block[tag] or {} -- TODO: make this pattern more flexible, accepting empty descriptions local _, _, name, desc = string.find(text, "^([_%w%.]+)%s+(.*)") if not name then luadoc.logger:warn("parameter `name' not defined [["..text.."]]: skipping") return end local i = table.foreachi(block[tag], function (i, v) if v == name then return i end end) if i == nil then luadoc.logger:warn(string.format("documenting undefined parameter `%s'", name)) table.insert(block[tag], name) end block[tag][name] = desc end ------------------------------------------------------------------------------- local function release (tag, block, text) block[tag] = text end ------------------------------------------------------------------------------- local function ret (tag, block, text) tag = "ret" if type(block[tag]) == "string" then block[tag] = { block[tag], text } elseif type(block[tag]) == "table" then table.insert(block[tag], text) else block[tag] = text end end ------------------------------------------------------------------------------- -- @see ret local function see (tag, block, text) -- see is always an array block[tag] = block[tag] or {} -- remove trailing "." text = string.gsub(text, "(.*)%.$", "%1") local s = util.split("%s*,%s*", text) table.foreachi(s, function (_, v) table.insert(block[tag], v) end) end ------------------------------------------------------------------------------- -- @see ret local function usage (tag, block, text) if type(block[tag]) == "string" then block[tag] = { block[tag], text } elseif type(block[tag]) == "table" then table.insert(block[tag], text) else block[tag] = text end end ------------------------------------------------------------------------------- local handlers = {} handlers["author"] = author handlers["class"] = class handlers["cstyle"] = cstyle handlers["copyright"] = copyright handlers["description"] = description handlers["field"] = field handlers["name"] = name handlers["param"] = param handlers["release"] = release handlers["return"] = ret handlers["see"] = see handlers["usage"] = usage ------------------------------------------------------------------------------- function handle (tag, block, text) if not handlers[tag] then luadoc.logger:error(string.format("undefined handler for tag `%s'", tag)) return end -- assert(handlers[tag], string.format("undefined handler for tag `%s'", tag)) return handlers[tag](tag, block, text) end
gpl-2.0
arya5123/tell
plugins/stats.lua
866
4001
do -- Returns a table with `name` and `msgs` local function get_msgs_user_chat(user_id, chat_id) local user_info = {} local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info.msgs = tonumber(redis:get(um_hash) or 0) user_info.name = user_print_name(user)..' ['..user_id..']' return user_info end local function chat_stats(chat_id) -- Users on chat local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} -- Get user info for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end -- Sort users by msgs number table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'users in this chat \n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w") file:write(text) file:flush() file:close() send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false) return --text end local function chat_stats2(chat_id) -- Users on chat local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} -- Get user info for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end -- Sort users by msgs number table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'users in this chat \n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end return text end -- Save stats, ban user local function bot_stats() local redis_scan = [[ local cursor = '0' local count = 0 repeat local r = redis.call("SCAN", cursor, "MATCH", KEYS[1]) cursor = r[1] count = count + #r[2] until cursor == '0' return count]] -- Users local hash = 'msgs:*:'..our_id local r = redis:eval(redis_scan, 1, hash) local text = 'Users: '..r hash = 'chat:*:users' r = redis:eval(redis_scan, 1, hash) text = text..'\nGroups: '..r return text end local function run(msg, matches) if matches[1]:lower() == 'teleseed' then -- Put everything you like :) local about = _config.about_text local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] used /teleseed ") return about end if matches[1]:lower() == "statslist" then if not is_momod(msg) then return "For mods only !" end local chat_id = msg.to.id local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ") return chat_stats2(chat_id) end if matches[1]:lower() == "stats" then if not matches[2] then if not is_momod(msg) then return "For mods only !" end if msg.to.type == 'chat' then local chat_id = msg.to.id local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ") return chat_stats(chat_id) else return end end if matches[2] == "teleseed" then -- Put everything you like :) if not is_admin(msg) then return "For admins only !" else return bot_stats() end end if matches[2] == "group" then if not is_admin(msg) then return "For admins only !" else return chat_stats(matches[3]) end end end end return { patterns = { "^[!/]([Ss]tats)$", "^[!/]([Ss]tatslist)$", "^[!/]([Ss]tats) (group) (%d+)", "^[!/]([Ss]tats) (teleseed)",-- Put everything you like :) "^[!/]([Tt]eleseed)"-- Put everything you like :) }, run = run } end
gpl-2.0
cecile/Cecile_QuickLaunch
src/Cecile_QuickLaunch/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
20
12722
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\ -- Options tables can be registered as raw tables, OR as function refs that return a table.\\ -- Such functions receive three arguments: "uiType", "uiName", "appName". \\ -- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\ -- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\ -- * The **appName** field is the options table name as given at registration time \\ -- -- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". -- @class file -- @name AceConfigRegistry-3.0 -- @release $Id: AceConfigRegistry-3.0.lua 1207 2019-06-23 12:08:33Z nevcairiel $ local CallbackHandler = LibStub("CallbackHandler-1.0") local MAJOR, MINOR = "AceConfigRegistry-3.0", 20 local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) if not AceConfigRegistry then return end AceConfigRegistry.tables = AceConfigRegistry.tables or {} if not AceConfigRegistry.callbacks then AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry) end -- Lua APIs local tinsert, tconcat = table.insert, table.concat local strfind, strmatch = string.find, string.match local type, tostring, select, pairs = type, tostring, select, pairs local error, assert = error, assert ----------------------------------------------------------------------- -- Validating options table consistency: AceConfigRegistry.validated = { -- list of options table names ran through :ValidateOptionsTable automatically. -- CLEARED ON PURPOSE, since newer versions may have newer validators cmd = {}, dropdown = {}, dialog = {}, } local function err(msg, errlvl, ...) local t = {} for i=select("#",...),1,-1 do tinsert(t, (select(i, ...))) end error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2) end local isstring={["string"]=true, _="string"} local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"} local istable={["table"]=true, _="table"} local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"} local optstring={["nil"]=true,["string"]=true, _="string"} local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"} local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"} local optnumber={["nil"]=true,["number"]=true, _="number"} local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"} local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"} local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"} local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"} local opttable={["nil"]=true,["table"]=true, _="table"} local optbool={["nil"]=true,["boolean"]=true, _="boolean"} local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"} local optstringnumber={["nil"]=true,["string"]=true,["number"]=true, _="string or number"} local basekeys={ type=isstring, name=isstringfunc, desc=optstringfunc, descStyle=optstring, order=optmethodnumber, validate=optmethodfalse, confirm=optmethodbool, confirmText=optstring, disabled=optmethodbool, hidden=optmethodbool, guiHidden=optmethodbool, dialogHidden=optmethodbool, dropdownHidden=optmethodbool, cmdHidden=optmethodbool, icon=optstringnumberfunc, iconCoords=optmethodtable, handler=opttable, get=optmethodfalse, set=optmethodfalse, func=optmethodfalse, arg={["*"]=true}, width=optstringnumber, } local typedkeys={ header={ control=optstring, dialogControl=optstring, dropdownControl=optstring, }, description={ image=optstringnumberfunc, imageCoords=optmethodtable, imageHeight=optnumber, imageWidth=optnumber, fontSize=optstringfunc, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, group={ args=istable, plugins=opttable, inline=optbool, cmdInline=optbool, guiInline=optbool, dropdownInline=optbool, dialogInline=optbool, childGroups=optstring, }, execute={ image=optstringnumberfunc, imageCoords=optmethodtable, imageHeight=optnumber, imageWidth=optnumber, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, input={ pattern=optstring, usage=optstring, control=optstring, dialogControl=optstring, dropdownControl=optstring, multiline=optboolnumber, }, toggle={ tristate=optbool, image=optstringnumberfunc, imageCoords=optmethodtable, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, tristate={ }, range={ min=optnumber, softMin=optnumber, max=optnumber, softMax=optnumber, step=optnumber, bigStep=optnumber, isPercent=optbool, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, select={ values=ismethodtable, sorting=optmethodtable, style={ ["nil"]=true, ["string"]={dropdown=true,radio=true}, _="string: 'dropdown' or 'radio'" }, control=optstring, dialogControl=optstring, dropdownControl=optstring, itemControl=optstring, }, multiselect={ values=ismethodtable, style=optstring, tristate=optbool, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, color={ hasAlpha=optmethodbool, control=optstring, dialogControl=optstring, dropdownControl=optstring, }, keybinding={ control=optstring, dialogControl=optstring, dropdownControl=optstring, }, } local function validateKey(k,errlvl,...) errlvl=(errlvl or 0)+1 if type(k)~="string" then err("["..tostring(k).."] - key is not a string", errlvl,...) end if strfind(k, "[%c\127]") then err("["..tostring(k).."] - key name contained control characters", errlvl,...) end end local function validateVal(v, oktypes, errlvl,...) errlvl=(errlvl or 0)+1 local isok=oktypes[type(v)] or oktypes["*"] if not isok then err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...) end if type(isok)=="table" then -- isok was a table containing specific values to be tested for! if not isok[v] then err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...) end end end local function validate(options,errlvl,...) errlvl=(errlvl or 0)+1 -- basic consistency if type(options)~="table" then err(": expected a table, got a "..type(options), errlvl,...) end if type(options.type)~="string" then err(".type: expected a string, got a "..type(options.type), errlvl,...) end -- get type and 'typedkeys' member local tk = typedkeys[options.type] if not tk then err(".type: unknown type '"..options.type.."'", errlvl,...) end -- make sure that all options[] are known parameters for k,v in pairs(options) do if not (tk[k] or basekeys[k]) then err(": unknown parameter", errlvl,tostring(k),...) end end -- verify that required params are there, and that everything is the right type for k,oktypes in pairs(basekeys) do validateVal(options[k], oktypes, errlvl,k,...) end for k,oktypes in pairs(tk) do validateVal(options[k], oktypes, errlvl,k,...) end -- extra logic for groups if options.type=="group" then for k,v in pairs(options.args) do validateKey(k,errlvl,"args",...) validate(v, errlvl,k,"args",...) end if options.plugins then for plugname,plugin in pairs(options.plugins) do if type(plugin)~="table" then err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...) end for k,v in pairs(plugin) do validateKey(k,errlvl,tostring(plugname),"plugins",...) validate(v, errlvl,k,tostring(plugname),"plugins",...) end end end end end --- Validates basic structure and integrity of an options table \\ -- Does NOT verify that get/set etc actually exist, since they can be defined at any depth -- @param options The table to be validated -- @param name The name of the table to be validated (shown in any error message) -- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable) function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl) errlvl=(errlvl or 0)+1 name = name or "Optionstable" if not options.name then options.name=name -- bit of a hack, the root level doesn't really need a .name :-/ end validate(options,errlvl,name) end --- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh. -- You should call this function if your options table changed from any outside event, like a game event -- or a timer. -- @param appName The application name as given to `:RegisterOptionsTable()` function AceConfigRegistry:NotifyChange(appName) if not AceConfigRegistry.tables[appName] then return end AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName) end -- ------------------------------------------------------------------- -- Registering and retreiving options tables: -- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it) local function validateGetterArgs(uiType, uiName, errlvl) errlvl=(errlvl or 0)+2 if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl) end if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2" error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl) end end --- Register an options table with the config registry. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param options The options table, OR a function reference that generates it on demand. \\ -- See the top of the page for info on arguments passed to such functions. -- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown) function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation) if type(options)=="table" then if options.type~="group" then -- quick sanity checker error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2) end AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) errlvl=(errlvl or 0)+1 validateGetterArgs(uiType, uiName, errlvl) if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable AceConfigRegistry.validated[uiType][appName] = true end return options end elseif type(options)=="function" then AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) errlvl=(errlvl or 0)+1 validateGetterArgs(uiType, uiName, errlvl) local tab = assert(options(uiType, uiName, appName)) if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable AceConfigRegistry.validated[uiType][appName] = true end return tab end else error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2) end end --- Returns an iterator of ["appName"]=funcref pairs function AceConfigRegistry:IterateOptionsTables() return pairs(AceConfigRegistry.tables) end --- Query the registry for a specific options table. -- If only appName is given, a function is returned which you -- can call with (uiType,uiName) to get the table.\\ -- If uiType&uiName are given, the table is returned. -- @param appName The application name as given to `:RegisterOptionsTable()` -- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog" -- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0" function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName) local f = AceConfigRegistry.tables[appName] if not f then return nil end if uiType then return f(uiType,uiName,1) -- get the table for us else return f -- return the function end end
artistic-2.0
arya5123/tell
plugins/location.lua
185
1565
-- Implement a command !loc [area] which uses -- the static map API to get a location image -- Not sure if this is the proper way -- Intent: get_latlong is in time.lua, we need it here -- loadfile "time.lua" -- Globals -- If you have a google api key for the geocoding/timezone api do local api_key = nil local base_api = "https://maps.googleapis.com/maps/api" function get_staticmap(area) local api = base_api .. "/staticmap?" -- Get a sense of scale local lat,lng,acc,types = get_latlong(area) local scale = types[1] if scale=="locality" then zoom=8 elseif scale=="country" then zoom=4 else zoom = 13 end local parameters = "size=600x300" .. "&zoom=" .. zoom .. "&center=" .. URL.escape(area) .. "&markers=color:red"..URL.escape("|"..area) if api_key ~=nil and api_key ~= "" then parameters = parameters .. "&key="..api_key end return lat, lng, api..parameters end function run(msg, matches) local receiver = get_receiver(msg) local lat,lng,url = get_staticmap(matches[1]) -- Send the actual location, is a google maps link send_location(receiver, lat, lng, ok_cb, false) -- Send a picture of the map, which takes scale into account send_photo_from_url(receiver, url) -- Return a link to the google maps stuff is now not needed anymore return nil end return { description = "Gets information about a location, maplink and overview", usage = "!loc (location): Gets information about a location, maplink and overview", patterns = {"^!loc (.*)$"}, run = run } end
gpl-2.0
nobie/sesame_fw
feeds/luci/libs/core/luasrc/model/firewall.lua
84
11156
--[[ LuCI - Firewall model Copyright 2009 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ]]-- local type, pairs, ipairs, table, luci, math = type, pairs, ipairs, table, luci, math local tpl = require "luci.template.parser" local utl = require "luci.util" local uci = require "luci.model.uci" module "luci.model.firewall" local uci_r, uci_s function _valid_id(x) return (x and #x > 0 and x:match("^[a-zA-Z0-9_]+$")) end function _get(c, s, o) return uci_r:get(c, s, o) end function _set(c, s, o, v) if v ~= nil then if type(v) == "boolean" then v = v and "1" or "0" end return uci_r:set(c, s, o, v) else return uci_r:delete(c, s, o) end end function init(cursor) uci_r = cursor or uci_r or uci.cursor() uci_s = uci_r:substate() return _M end function save(self, ...) uci_r:save(...) uci_r:load(...) end function commit(self, ...) uci_r:commit(...) uci_r:load(...) end function get_defaults() return defaults() end function new_zone(self) local name = "newzone" local count = 1 while self:get_zone(name) do count = count + 1 name = "newzone%d" % count end return self:add_zone(name) end function add_zone(self, n) if _valid_id(n) and not self:get_zone(n) then local d = defaults() local z = uci_r:section("firewall", "zone", nil, { name = n, network = " ", input = d:input() or "DROP", forward = d:forward() or "DROP", output = d:output() or "DROP" }) return z and zone(z) end end function get_zone(self, n) if uci_r:get("firewall", n) == "zone" then return zone(n) else local z uci_r:foreach("firewall", "zone", function(s) if n and s.name == n then z = s['.name'] return false end end) return z and zone(z) end end function get_zones(self) local zones = { } local znl = { } uci_r:foreach("firewall", "zone", function(s) if s.name then znl[s.name] = zone(s['.name']) end end) local z for z in utl.kspairs(znl) do zones[#zones+1] = znl[z] end return zones end function get_zone_by_network(self, net) local z uci_r:foreach("firewall", "zone", function(s) if s.name and net then local n for n in utl.imatch(s.network or s.name) do if n == net then z = s['.name'] return false end end end end) return z and zone(z) end function del_zone(self, n) local r = false if uci_r:get("firewall", n) == "zone" then local z = uci_r:get("firewall", n, "name") r = uci_r:delete("firewall", n) n = z else uci_r:foreach("firewall", "zone", function(s) if n and s.name == n then r = uci_r:delete("firewall", s['.name']) return false end end) end if r then uci_r:foreach("firewall", "rule", function(s) if s.src == n or s.dest == n then uci_r:delete("firewall", s['.name']) end end) uci_r:foreach("firewall", "redirect", function(s) if s.src == n or s.dest == n then uci_r:delete("firewall", s['.name']) end end) uci_r:foreach("firewall", "forwarding", function(s) if s.src == n or s.dest == n then uci_r:delete("firewall", s['.name']) end end) end return r end function rename_zone(self, old, new) local r = false if _valid_id(new) and not self:get_zone(new) then uci_r:foreach("firewall", "zone", function(s) if old and s.name == old then if not s.network then uci_r:set("firewall", s['.name'], "network", old) end uci_r:set("firewall", s['.name'], "name", new) r = true return false end end) if r then uci_r:foreach("firewall", "rule", function(s) if s.src == old then uci_r:set("firewall", s['.name'], "src", new) end if s.dest == old then uci_r:set("firewall", s['.name'], "dest", new) end end) uci_r:foreach("firewall", "redirect", function(s) if s.src == old then uci_r:set("firewall", s['.name'], "src", new) end if s.dest == old then uci_r:set("firewall", s['.name'], "dest", new) end end) uci_r:foreach("firewall", "forwarding", function(s) if s.src == old then uci_r:set("firewall", s['.name'], "src", new) end if s.dest == old then uci_r:set("firewall", s['.name'], "dest", new) end end) end end return r end function del_network(self, net) local z if net then for _, z in ipairs(self:get_zones()) do z:del_network(net) end end end defaults = utl.class() function defaults.__init__(self) uci_r:foreach("firewall", "defaults", function(s) self.sid = s['.name'] return false end) self.sid = self.sid or uci_r:section("firewall", "defaults", nil, { }) end function defaults.get(self, opt) return _get("firewall", self.sid, opt) end function defaults.set(self, opt, val) return _set("firewall", self.sid, opt, val) end function defaults.syn_flood(self) return (self:get("syn_flood") == "1") end function defaults.drop_invalid(self) return (self:get("drop_invalid") == "1") end function defaults.input(self) return self:get("input") or "DROP" end function defaults.forward(self) return self:get("forward") or "DROP" end function defaults.output(self) return self:get("output") or "DROP" end zone = utl.class() function zone.__init__(self, z) if uci_r:get("firewall", z) == "zone" then self.sid = z self.data = uci_r:get_all("firewall", z) else uci_r:foreach("firewall", "zone", function(s) if s.name == z then self.sid = s['.name'] self.data = s return false end end) end end function zone.get(self, opt) return _get("firewall", self.sid, opt) end function zone.set(self, opt, val) return _set("firewall", self.sid, opt, val) end function zone.masq(self) return (self:get("masq") == "1") end function zone.name(self) return self:get("name") end function zone.network(self) return self:get("network") end function zone.input(self) return self:get("input") or defaults():input() or "DROP" end function zone.forward(self) return self:get("forward") or defaults():forward() or "DROP" end function zone.output(self) return self:get("output") or defaults():output() or "DROP" end function zone.add_network(self, net) if uci_r:get("network", net) == "interface" then local nets = { } local n for n in utl.imatch(self:get("network") or self:get("name")) do if n ~= net then nets[#nets+1] = n end end nets[#nets+1] = net _M:del_network(net) self:set("network", table.concat(nets, " ")) end end function zone.del_network(self, net) local nets = { } local n for n in utl.imatch(self:get("network") or self:get("name")) do if n ~= net then nets[#nets+1] = n end end if #nets > 0 then self:set("network", table.concat(nets, " ")) else self:set("network", " ") end end function zone.get_networks(self) local nets = { } local n for n in utl.imatch(self:get("network") or self:get("name")) do nets[#nets+1] = n end return nets end function zone.clear_networks(self) self:set("network", " ") end function zone.get_forwardings_by(self, what) local name = self:name() local forwards = { } uci_r:foreach("firewall", "forwarding", function(s) if s.src and s.dest and s[what] == name then forwards[#forwards+1] = forwarding(s['.name']) end end) return forwards end function zone.add_forwarding_to(self, dest) local exist, forward for _, forward in ipairs(self:get_forwardings_by('src')) do if forward:dest() == dest then exist = true break end end if not exist and dest ~= self:name() and _valid_id(dest) then local s = uci_r:section("firewall", "forwarding", nil, { src = self:name(), dest = dest }) return s and forwarding(s) end end function zone.add_forwarding_from(self, src) local exist, forward for _, forward in ipairs(self:get_forwardings_by('dest')) do if forward:src() == src then exist = true break end end if not exist and src ~= self:name() and _valid_id(src) then local s = uci_r:section("firewall", "forwarding", nil, { src = src, dest = self:name() }) return s and forwarding(s) end end function zone.del_forwardings_by(self, what) local name = self:name() uci_r:delete_all("firewall", "forwarding", function(s) return (s.src and s.dest and s[what] == name) end) end function zone.add_redirect(self, options) options = options or { } options.src = self:name() local s = uci_r:section("firewall", "redirect", nil, options) return s and redirect(s) end function zone.add_rule(self, options) options = options or { } options.src = self:name() local s = uci_r:section("firewall", "rule", nil, options) return s and rule(s) end function zone.get_color(self) if self and self:name() == "lan" then return "#90f090" elseif self and self:name() == "wan" then return "#f09090" elseif self then math.randomseed(tpl.hash(self:name())) local r = math.random(128) local g = math.random(128) local min = 0 local max = 128 if ( r + g ) < 128 then min = 128 - r - g else max = 255 - r - g end local b = min + math.floor( math.random() * ( max - min ) ) return "#%02x%02x%02x" % { 0xFF - r, 0xFF - g, 0xFF - b } else return "#eeeeee" end end forwarding = utl.class() function forwarding.__init__(self, f) self.sid = f end function forwarding.src(self) return uci_r:get("firewall", self.sid, "src") end function forwarding.dest(self) return uci_r:get("firewall", self.sid, "dest") end function forwarding.src_zone(self) return zone(self:src()) end function forwarding.dest_zone(self) return zone(self:dest()) end rule = utl.class() function rule.__init__(self, f) self.sid = f end function rule.get(self, opt) return _get("firewall", self.sid, opt) end function rule.set(self, opt, val) return _set("firewall", self.sid, opt, val) end function rule.src(self) return uci_r:get("firewall", self.sid, "src") end function rule.dest(self) return uci_r:get("firewall", self.sid, "dest") end function rule.src_zone(self) return zone(self:src()) end function rule.dest_zone(self) return zone(self:dest()) end redirect = utl.class() function redirect.__init__(self, f) self.sid = f end function redirect.get(self, opt) return _get("firewall", self.sid, opt) end function redirect.set(self, opt, val) return _set("firewall", self.sid, opt, val) end function redirect.src(self) return uci_r:get("firewall", self.sid, "src") end function redirect.dest(self) return uci_r:get("firewall", self.sid, "dest") end function redirect.src_zone(self) return zone(self:src()) end function redirect.dest_zone(self) return zone(self:dest()) end
gpl-2.0
KayMD/Illarion-Content
quest/lotte_silberstreif_672.lua
3
2793
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- INSERT INTO "quests" ("qst_id", "qst_script") VALUES (672, 'quest.lotte_silberstreif_672'); local common = require("base.common") local M = {} local GERMAN = Player.german local ENGLISH = Player.english -- Insert the quest title here, in both languages local Title = {} Title[GERMAN] = "Galmairs Lotterie" Title[ENGLISH] = "Galmair's lotto game" -- Insert an extensive description of each status here, in both languages -- Make sure that the player knows exactly where to go and what to do local Description = {} Description[GERMAN] = {} Description[ENGLISH] = {} Description[GERMAN][1] = "Du hast ein Los gekauft. Sprich mit Lotte Silberstreif um dein Los zu ziehen." Description[ENGLISH][1] = "You bought one lot. Talk to Lotte Silberstreif to use your lot." Description[GERMAN][2] = "Du hast 5 Lose gekauft. Sprich mit Lotte Silberstreif um deine Lose zu ziehen." Description[ENGLISH][2] = "You bought five lots. Talk to Lotte Silberstreif to use your lots." Description[GERMAN][10] = "Bring Lotte Silberstreif einen Apfel." Description[ENGLISH][10] = "Bring one apple to Lotte Silberstreif." Description[GERMAN][20] = "Bring Lotte Silberstreif 5 Kirschen." Description[ENGLISH][20] = "Bring five cherries to Lotte Silberstreif." -- For each status insert a list of positions where the quest will continue, i.e. a new status can be reached there local QuestTarget = {} QuestTarget[1] = {position(295, 283, -6)} -- Lotte QuestTarget[2] = {position(295, 283, -6)} -- Lotte QuestTarget[10] = {position(295, 283, -6)} -- Lotte QuestTarget[20] = {position(295, 283, -6)} -- Lotte -- Insert the quest status which is reached at the end of the quest local FINAL_QUEST_STATUS = 0 function M.QuestTitle(user) return common.GetNLS(user, Title[GERMAN], Title[ENGLISH]) end function M.QuestDescription(user, status) local german = Description[GERMAN][status] or "" local english = Description[ENGLISH][status] or "" return common.GetNLS(user, german, english) end function M.QuestTargets(user, status) return QuestTarget[status] end function M.QuestFinalStatus() return FINAL_QUEST_STATUS end return M
agpl-3.0
KayMD/Illarion-Content
craft/final/armourer.lua
2
29557
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] local crafts = require("craft.base.crafts") local M = {} local armourer = crafts.Craft:new{ craftEN = "Armourer", craftDE = "Rüstschmied", handTool = 2709, leadSkill = Character.armourer, sfx = 8, sfxDuration = 27, } armourer:addTool(172) -- anvil local product local catId catId = armourer:addCategory("Chain boots", "Kettenstiefel") -- simple jackboots product = armourer:addProduct(catId, 1507, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2547, 1) -- leather -- jackboots product = armourer:addProduct(catId, 1508, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2547, 1) -- leather -- robust jackboots product = armourer:addProduct(catId, 1057, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2547, 1) -- leather -- guardian's boots product = armourer:addProduct(catId, 1056, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2547, 1) -- leather -- silversteel boots product = armourer:addProduct(catId, 1058, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2547, 1) -- leather product:addIngredient(104, 1) -- silver ingot product:addIngredient(197, 1) -- amethyst -- coppered guardian's boots product = armourer:addProduct(catId, 1509, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2547, 1) -- leather product:addIngredient(2550, 1) -- copper ingot product:addIngredient(46, 1) -- ruby -- ornate jackboots product = armourer:addProduct(catId, 1054, 1) product:addIngredient(2535, 4) -- thread product:addIngredient(2547, 1) -- leather product:addIngredient(2550, 2) -- copper ingot product:addIngredient(283, 1) -- obsidian -- silvered guardian's boots product = armourer:addProduct(catId, 1510, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(104, 2) -- silver ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 1) -- copper ingot -- gilded guardian's boots product = armourer:addProduct(catId, 1511, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(236, 1) -- gold ingot -- salkamaerian steel shoes product = armourer:addProduct(catId, 699, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 1) -- gold ingot -- master's steel shoes product = armourer:addProduct(catId, 1512, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2552, 1) -- pure earth catId = armourer:addCategory("Chain gloves", "Kettenhandschuhe") -- simple chain gloves product = armourer:addProduct(catId, 1460, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(176, 1) -- grey cloth -- chain gloves product = armourer:addProduct(catId, 1461, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(176, 1) -- grey cloth -- reinforced chain gloves product = armourer:addProduct(catId, 1462, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(176, 1) -- grey cloth -- coppered chain gloves product = armourer:addProduct(catId, 1463, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(2550, 1) -- copper ingot -- silvered chain gloves product = armourer:addProduct(catId, 1464, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(104, 1) -- silver ingot product:addIngredient(197, 1) -- amethyst -- salkamaerian chain gloves product = armourer:addProduct(catId, 528, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(104, 1) -- silver ingot product:addIngredient(46, 1) -- ruby -- gilded chain gloves product = armourer:addProduct(catId, 1465, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(236, 1) -- gold ingot product:addIngredient(284, 1) -- sapphire -- guard's chain gloves product = armourer:addProduct(catId, 1466, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(236, 2) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 1) -- copper ingot -- gladiator's chain gloves product = armourer:addProduct(catId, 1467, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 1) -- silver ingot -- merinium plated chain gloves product = armourer:addProduct(catId, 1468, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 1) -- gold ingot -- templar's chain gloves product = armourer:addProduct(catId, 1469, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2554, 1) -- pure water catId = armourer:addCategory("Chain greaves", "Kettenhosen") -- simple short scale greaves product = armourer:addProduct(catId, 1485, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2547, 1) -- leather -- short scale greaves product = armourer:addProduct(catId, 2194, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2547, 1) -- leather -- reinforced short scale greaves product = armourer:addProduct(catId, 1486, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2547, 1) -- leather -- simple scale greaves product = armourer:addProduct(catId, 1487, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2547, 1) -- leather -- scale greaves product = armourer:addProduct(catId, 2193, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(2550, 2) -- copper ingot product:addIngredient(197, 1) -- amethyst -- reinforced scale greaves product = armourer:addProduct(catId, 1488, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(104, 2) -- silver ingot product:addIngredient(46, 1) -- ruby -- simple chain trousers product = armourer:addProduct(catId, 1489, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2547, 2) -- leather product:addIngredient(104, 2) -- silver ingot product:addIngredient(284, 1) -- sapphire -- short chain trousers product = armourer:addProduct(catId, 2112, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(2547, 3) -- leather product:addIngredient(236, 3) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 2) -- copper ingot -- reinforced chain trousers product = armourer:addProduct(catId, 1490, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(2547, 3) -- leather product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 2) -- silver ingot -- chain pants product = armourer:addProduct(catId, 2111, 1) product:addIngredient(2535, 9) -- iron ingot product:addIngredient(2547, 3) -- leather product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 2) -- gold ingot -- holy chain pants product = armourer:addProduct(catId, 1491, 1) product:addIngredient(2535, 10) -- iron ingot product:addIngredient(2547, 3) -- leather product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2554, 1) -- pure water catId = armourer:addCategory("Chain helmets", "Kettenhelme") -- chain helmet product = armourer:addProduct(catId, 324, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(176, 1) -- grey cloth -- orc helmet product = armourer:addProduct(catId, 16, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(176, 1) -- grey cloth -- coppered chain helmet product = armourer:addProduct(catId, 1425, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(2550, 1) -- copper ingot -- serinjah helmet product = armourer:addProduct(catId, 2444, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(2550, 1) -- copper ingot -- silvered chain helmet product = armourer:addProduct(catId, 1426, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(176, 1) -- grey cloth product:addIngredient(104, 1) -- silver ingot product:addIngredient(197, 1) -- amethyst -- storm cap product = armourer:addProduct(catId, 2441, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(104, 2) -- silver ingot product:addIngredient(46, 1) -- ruby -- gilded chain helmet product = armourer:addProduct(catId, 1427, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(236, 2) -- gold ingot product:addIngredient(284, 1) -- sapphire -- gynkese mercenary's helmet product = armourer:addProduct(catId, 2302, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(236, 2) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 2) -- copper ingot -- chain helmet of darkness product = armourer:addProduct(catId, 1428, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 2) -- silver ingot -- salkamaerian paladin's helmet product = armourer:addProduct(catId, 2291, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(176, 2) -- grey cloth product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 2) -- gold ingot -- flame helmet product = armourer:addProduct(catId, 2286, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(176, 3) -- grey cloth product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2553, 1) -- pure fire catId = armourer:addCategory("Chain mails", "Kettenhemden") -- chain mail product = armourer:addProduct(catId, 101, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2547, 1) -- leather -- mercenary armour product = armourer:addProduct(catId, 2359, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2547, 2) -- leather -- guardian's armour product = armourer:addProduct(catId, 2360, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2547, 2) -- leather -- scale armour product = armourer:addProduct(catId, 1095, 1) product:addIngredient(2535, 9) -- iron ingot product:addIngredient(2547, 3) -- leather -- silversteel armour product = armourer:addProduct(catId, 2403, 1) product:addIngredient(2535, 10) -- iron ingot product:addIngredient(2547, 3) -- leather product:addIngredient(104, 3) -- silver ingot product:addIngredient(197, 1) -- amethyst -- coppered scale armour product = armourer:addProduct(catId, 1438, 1) product:addIngredient(2535, 12) -- iron ingot product:addIngredient(2547, 4) -- leather product:addIngredient(2550, 4) -- copper ingot product:addIngredient(46, 1) -- ruby -- lizard armour product = armourer:addProduct(catId, 696, 1) product:addIngredient(2535, 13) -- iron ingot product:addIngredient(2547, 4) -- leather product:addIngredient(2550, 4) -- copper ingot product:addIngredient(284, 1) -- sapphire -- silvered scale armour product = armourer:addProduct(catId, 1439, 1) product:addIngredient(2535, 14) -- iron ingot product:addIngredient(2547, 5) -- leather product:addIngredient(104, 5) -- silver ingot product:addIngredient(284, 1) -- sapphire product:addIngredient(2550, 4) -- copper ingot -- salkamaerian armour product = armourer:addProduct(catId, 2389, 1) product:addIngredient(2535, 15) -- iron ingot product:addIngredient(2547, 6) -- leather product:addIngredient(236, 6) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 4) -- copper ingot -- gilded scale armour product = armourer:addProduct(catId, 1440, 1) product:addIngredient(2535, 17) -- iron ingot product:addIngredient(2547, 6) -- leather product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(236, 4) -- gold ingot -- salkamaerian officer's armour product = armourer:addProduct(catId, 2365, 1) product:addIngredient(2535, 18) -- iron ingot product:addIngredient(2547, 6) -- leather product:addIngredient(2571, 3) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 4) -- gold ingot -- state armour product = armourer:addProduct(catId, 2400, 1) product:addIngredient(2535, 20) -- iron ingot product:addIngredient(2547, 7) -- leather product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(3607, 1) -- pure spirit catId = armourer:addCategory("Plate boots", "Panzerstiefel") -- iron boots product = armourer:addProduct(catId, 1520, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- simple steel boots product = armourer:addProduct(catId, 1513, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- steel boots product = armourer:addProduct(catId, 326, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced steel boots product = armourer:addProduct(catId, 1514, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- coppered steel boots product = armourer:addProduct(catId, 1515, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(2550, 1) -- copper ingot product:addIngredient(197, 1) -- amethyst -- dwarven boots product = armourer:addProduct(catId, 1055, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(2550, 1) -- copper ingot product:addIngredient(46, 1) -- ruby -- silvered steel boots product = armourer:addProduct(catId, 1516, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(104, 1) -- silver ingot product:addIngredient(46, 1) -- ruby -- albarian steel boots product = armourer:addProduct(catId, 771, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(236, 1) -- gold ingot product:addIngredient(284, 1) -- sapphire -- gilded steel boots product = armourer:addProduct(catId, 1517, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(236, 2) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 1) -- copper ingot -- paladin's steel boots product = armourer:addProduct(catId, 1518, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 1) -- silver ingot -- knight boots product = armourer:addProduct(catId, 770, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 1) -- gold ingot -- knight boots of swiftness product = armourer:addProduct(catId, 1519, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2551, 1) -- pure air catId = armourer:addCategory("Plate gloves", "Panzerhandschuhe") -- simple steel gloves product = armourer:addProduct(catId, 1470, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- steel gloves product = armourer:addProduct(catId, 325, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced steel gloves product = armourer:addProduct(catId, 1471, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- coppered steel gloves product = armourer:addProduct(catId, 1472, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(2550, 1) -- copper ingot -- silvered steel gloves product = armourer:addProduct(catId, 1473, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(104, 1) -- silver ingot product:addIngredient(197, 1) -- amethyst -- dwarven metal gloves product = armourer:addProduct(catId, 529, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(104, 1) -- silver ingot product:addIngredient(46, 1) -- ruby -- gilded steel gloves product = armourer:addProduct(catId, 1474, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(236, 1) -- gold ingot product:addIngredient(46, 1) -- ruby -- squire's gloves product = armourer:addProduct(catId, 1475, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(236, 1) -- gold ingot product:addIngredient(284, 1) -- sapphire -- albarian steel gloves product = armourer:addProduct(catId, 530, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(236, 2) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 1) -- copper ingot -- knight gloves product = armourer:addProduct(catId, 531, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 1) -- silver ingot -- merinium plated steel gloves product = armourer:addProduct(catId, 1476, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 1) -- gold ingot -- grand master's gloves product = armourer:addProduct(catId, 1477, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2552, 1) -- pure earth catId = armourer:addCategory("Plate greaves", "Panzerhosen") -- simple short iron greaves product = armourer:addProduct(catId, 1492, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- short iron greaves product = armourer:addProduct(catId, 2117, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced short iron greaves product = armourer:addProduct(catId, 1493, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- simple iron greaves product = armourer:addProduct(catId, 1494, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- iron greaves product = armourer:addProduct(catId, 2116, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2550, 2) -- copper ingot product:addIngredient(197, 1) -- amethyst -- reinforced iron greaves product = armourer:addProduct(catId, 1495, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(104, 2) -- silver ingot product:addIngredient(46, 1) -- ruby -- simple steel greaves product = armourer:addProduct(catId, 1496, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(104, 2) -- silver ingot product:addIngredient(284, 1) -- sapphire -- steel greaves product = armourer:addProduct(catId, 2172, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(236, 3) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 2) -- copper ingot -- reinforced steel greaves product = armourer:addProduct(catId, 1497, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 2) -- silver ingot -- knight's steel greaves product = armourer:addProduct(catId, 1498, 1) product:addIngredient(2535, 9) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 2) -- gold ingot -- steel greaves of eternal night product = armourer:addProduct(catId, 1499, 1) product:addIngredient(2535, 10) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2552, 1) -- pure earth catId = armourer:addCategory("Plate helmets", "Panzerhelme") -- steel cap product = armourer:addProduct(catId, 202, 1) product:addIngredient(2535, 1) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced steel cap product = armourer:addProduct(catId, 1429, 1) product:addIngredient(2535, 2) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- steel hat product = armourer:addProduct(catId, 187, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced steel hat product = armourer:addProduct(catId, 1430, 1) product:addIngredient(2535, 3) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- round steel hat product = armourer:addProduct(catId, 2290, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate product:addIngredient(2550, 1) -- copper ingot product:addIngredient(197, 1) -- amethyst -- pot helmet product = armourer:addProduct(catId, 94, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(104, 2) -- silver ingot product:addIngredient(46, 1) -- ruby -- reinforced pot helmet product = armourer:addProduct(catId, 1431, 1) product:addIngredient(2535, 5) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(104, 2) -- silver ingot product:addIngredient(284, 1) -- sapphire -- albarian mercenary's helmet product = armourer:addProduct(catId, 1432, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(236, 2) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 2) -- copper ingot -- albarian soldier's helmet product = armourer:addProduct(catId, 2287, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 2) -- silver ingot -- visored helmet product = armourer:addProduct(catId, 184, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 2) -- gold ingot -- visored helmet of darkness product = armourer:addProduct(catId, 185, 1) product:addIngredient(2535, 8) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2552, 1) -- pure earth catId = armourer:addCategory("Plate armour", "Plattenpanzer") -- plate armour product = armourer:addProduct(catId, 4, 1) product:addIngredient(2535, 4) -- iron ingot product:addIngredient(2537, 1) -- iron plate -- reinforced plate armour product = armourer:addProduct(catId, 1441, 1) product:addIngredient(2535, 6) -- iron ingot product:addIngredient(2537, 2) -- iron plate -- steel plate product = armourer:addProduct(catId, 2364, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2537, 2) -- iron plate -- coppered plate armour product = armourer:addProduct(catId, 1443, 1) product:addIngredient(2535, 9) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2550, 3) -- copper ingot -- reinforced steel plate product = armourer:addProduct(catId, 1442, 1) product:addIngredient(2535, 10) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(2550, 3) -- copper ingot -- silvered plate armour product = armourer:addProduct(catId, 1444, 1) product:addIngredient(2535, 10) -- iron ingot product:addIngredient(2537, 3) -- iron plate product:addIngredient(104, 3) -- silver ingot product:addIngredient(197, 1) -- amethyst -- dwarven plate product = armourer:addProduct(catId, 2395, 1) product:addIngredient(2535, 11) -- iron ingot product:addIngredient(2537, 4) -- iron plate product:addIngredient(104, 4) -- silver ingot product:addIngredient(46, 1) -- ruby -- gilded plate armour product = armourer:addProduct(catId, 1445, 1) product:addIngredient(2535, 12) -- iron ingot product:addIngredient(2537, 4) -- iron plate product:addIngredient(236, 4) -- gold ingot product:addIngredient(46, 1) -- ruby -- albarian steel plate product = armourer:addProduct(catId, 2369, 1) product:addIngredient(2535, 14) -- iron ingot product:addIngredient(2537, 5) -- iron plate product:addIngredient(236, 5) -- gold ingot product:addIngredient(284, 1) -- sapphire -- dwarven state armour product = armourer:addProduct(catId, 2390, 1) product:addIngredient(2535, 14) -- iron ingot product:addIngredient(2537, 5) -- iron plate product:addIngredient(236, 5) -- gold ingot product:addIngredient(283, 1) -- obsidian -- albarian knight's armour product = armourer:addProduct(catId, 1446, 1) product:addIngredient(2535, 15) -- iron ingot product:addIngredient(2537, 5) -- iron plate product:addIngredient(236, 5) -- gold ingot product:addIngredient(283, 1) -- obsidian product:addIngredient(2550, 4) -- copper ingot -- albarian noble's armour product = armourer:addProduct(catId, 2367, 1) product:addIngredient(2535, 17) -- iron ingot product:addIngredient(2537, 6) -- iron plate product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(45, 1) -- emerald product:addIngredient(104, 4) -- silver ingot -- heavy plate armour product = armourer:addProduct(catId, 2393, 1) product:addIngredient(2535, 18) -- iron ingot product:addIngredient(2537, 6) -- iron plate product:addIngredient(2571, 3) -- merinium ingot product:addIngredient(198, 1) -- topaz product:addIngredient(236, 4) -- gold ingot -- nightplate product = armourer:addProduct(catId, 2363, 1) product:addIngredient(2535, 20) -- iron ingot product:addIngredient(2537, 7) -- iron plate product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(2552, 1) -- pure earth -- Dummy group for items that cannot be crafted but repaired catId = armourer:addCategory("repair only", "nur reparieren") -- drow helmet product = armourer:addProduct(catId, 2303, 1) product:addIngredient(2535, 7) -- iron ingot product:addIngredient(2537, 2) -- iron plate product:addIngredient(2571, 1) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(104, 2) -- silver ingot -- drow armour product = armourer:addProduct(catId, 2402, 1) product:addIngredient(2535, 18) -- iron ingot product:addIngredient(2537, 6) -- iron plate product:addIngredient(2571, 2) -- merinium ingot product:addIngredient(285, 1) -- diamond product:addIngredient(236, 4) -- gold ingot M.armourer = armourer return M
agpl-3.0
kooiot/kooweb
apps/cloud/model/device/actions.lua
1
2381
--- The actions saved the redis first then will be polled by device -- local redis = require 'resty.redis' local logger = require 'lwf.logger' local cjson = require 'cjson' local _M = {} local class = {} _M.new = function(m) local obj = { lwf = m.lwf, app = m.app, con = con } return setmetatable(obj, {__index=class}) end function class:init() if self.con then return true end local con = redis:new() con:set_timeout(500) -- print(con: get_reused_times()) local ok, err = con:connect('127.0.0.1', 6379) if not ok then --print(err) logger:error(err) return nil, err end con:select(10) self.con = con return true end function class:close() --print('close................') self.con:close() self.con = nil end function class:list(key) if not self.con then return nil, 'Db not initialized' end local r, err = self.con:smembers('actions.set.'..key) if not r then return nil, err or 'No value in db' end if r == ngx.null then return {} end local list = {} for _, v in ipairs(r) do local r, err = self.con:get('action.info.'..v) if r and r ~= ngx.null then list[#list + 1] = cjson.decode(r) else self.con:srem(v) end end return list end local function gen_id() local uuid = require 'lwf.util.uuid' return uuid() end function class:add(key, action) if not self.con then return nil, 'Db not initialized' end assert(action.name) action.id = action.id or gen_id() action.status = action.status or 'WAITING' local r, err = self.con:sadd('actions.set.'..key, action.id) if not r then return nil, err end local r, err = self.con:set('action.info.'..action.id, cjson.encode(action)) return r, err end function class:finish(key, id, result, err) if not self.con then return nil, 'Db not initialized' end assert(key and id) self.con:sadd('actions.set.done.'..key, id) r, err = self.con:srem('actions.set.'..key, id) if result then self:set_status(id, 'DONE') else self:set_status(id, 'ERROR', err) end end function class:set_status(id, status, err) if not self.con then return nil, 'Db not initialized' end local r, err = self.con:get('action.info.'..id) if not r or r == ngx.null then return nil, err or 'Not exits' end local action = cjson.decode(r) action.status = status action.err = err local r, err = self.con:set('action.info.'..id, cjson.encode(action)) end return _M
gpl-2.0
kw217/omim
3party/osrm/osrm-backend/profiles/testbot.lua
69
3444
-- Testbot profile -- Moves at fixed, well-known speeds, practical for testing speed and travel times: -- Primary road: 36km/h = 36000m/3600s = 100m/10s -- Secondary road: 18km/h = 18000m/3600s = 100m/20s -- Tertiary road: 12km/h = 12000m/3600s = 100m/30s -- modes: -- 1: normal -- 2: route -- 3: river downstream -- 4: river upstream -- 5: steps down -- 6: steps up speed_profile = { ["primary"] = 36, ["secondary"] = 18, ["tertiary"] = 12, ["steps"] = 6, ["default"] = 24 } -- these settings are read directly by osrm take_minimum_of_speeds = true obey_oneway = true obey_barriers = true use_turn_restrictions = true ignore_areas = true -- future feature traffic_signal_penalty = 7 -- seconds u_turn_penalty = 20 function limit_speed(speed, limits) -- don't use ipairs(), since it stops at the first nil value for i=1, #limits do limit = limits[i] if limit ~= nil and limit > 0 then if limit < speed then return limit -- stop at first speedlimit that's smaller than speed end end end return speed end function node_function (node, result) local traffic_signal = node:get_value_by_key("highway") if traffic_signal and traffic_signal == "traffic_signals" then result.traffic_lights = true; -- TODO: a way to set the penalty value end end function way_function (way, result) local highway = way:get_value_by_key("highway") local name = way:get_value_by_key("name") local oneway = way:get_value_by_key("oneway") local route = way:get_value_by_key("route") local duration = way:get_value_by_key("duration") local maxspeed = tonumber(way:get_value_by_key ( "maxspeed")) local maxspeed_forward = tonumber(way:get_value_by_key( "maxspeed:forward")) local maxspeed_backward = tonumber(way:get_value_by_key( "maxspeed:backward")) local junction = way:get_value_by_key("junction") if name then result.name = name end if duration and durationIsValid(duration) then result.duration = math.max( 1, parseDuration(duration) ) result.forward_mode = 2 result.backward_mode = 2 else local speed_forw = speed_profile[highway] or speed_profile['default'] local speed_back = speed_forw if highway == "river" then local temp_speed = speed_forw; result.forward_mode = 3 result.backward_mode = 4 speed_forw = temp_speed*1.5 speed_back = temp_speed/1.5 elseif highway == "steps" then result.forward_mode = 5 result.backward_mode = 6 end if maxspeed_forward ~= nil and maxspeed_forward > 0 then speed_forw = maxspeed_forward else if maxspeed ~= nil and maxspeed > 0 and speed_forw > maxspeed then speed_forw = maxspeed end end if maxspeed_backward ~= nil and maxspeed_backward > 0 then speed_back = maxspeed_backward else if maxspeed ~=nil and maxspeed > 0 and speed_back > maxspeed then speed_back = maxspeed end end result.forward_speed = speed_forw result.backward_speed = speed_back end if oneway == "no" or oneway == "0" or oneway == "false" then -- nothing to do elseif oneway == "-1" then result.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then result.backward_mode = 0 end if junction == 'roundabout' then result.roundabout = true end end
apache-2.0
kooiot/kooweb
lwf/ltp/template.lua
1
6553
-- -- Copyright 2007-2008 Savarese Software Research Corporation. -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.savarese.com/software/ApacheLicense-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- local ltp = require('ltp.util') local setfenv = setfenv local getfenv = getfenv if not setfenv then -- Lua 5.2 -- based on http://lua-users.org/lists/lua-l/2010-06/msg00314.html -- this assumes f is a function local function findenv(f) local level = 1 repeat local name, value = debug.getupvalue(f, level) if name == '_ENV' then return level, value end level = level + 1 until name == nil return nil end getfenv = function (f) return(select(2, findenv(f)) or _G) end setfenv = function (f, t) local level = findenv(f) if level then debug.setupvalue(f, level, t) end return f end end local function compile_template_to_table(result, data, start_lua, end_lua) local LF, CR, EQ = 10, 13, 61 local i1, i2, i3 i3 = 1 repeat i2, i1 = data:find(start_lua, i3, true) if i2 then if i3 < i2 then table.insert(result, "table.insert(output,") table.insert(result, string.format('%q', data:sub(i3, i2 - 1))) table.insert(result, ");") end i1 = i1 + 2 i2, i3 = data:find(end_lua, i1, true) if i2 then if data:byte(i1-1) == EQ then table.insert(result, "table.insert(output,") table.insert(result, data:sub(i1, i2 - 1)) table.insert(result, ");") i3 = i3 + 1 else table.insert(result, data:sub(i1, i2 - 1)) i3 = i3 + 1 if data:byte(i3) == LF then i3 = i3 + 1 elseif data:byte(i3) == CR and data:byte(i3+1) == LF then i3 = i3 + 2 end end end elseif i3 <= #data then table.insert(result, "table.insert(output,") table.insert(result, string.format('%q', data:sub(i3))) table.insert(result, ");") end until not i2 return result end local function compile_template_as_function(data, start_lua, end_lua) local result = { "return function(output) " } table.insert(compile_template_to_table(result, data, start_lua, end_lua), "end") return table.concat(result) end local function compile_template_as_chunk(data, start_lua, end_lua) local result = { "local output = ... " } return table.concat(compile_template_to_table(result, data, start_lua, end_lua)) end local function compile_template(data, start_lua, end_lua) return table.concat(compile_template_to_table({ }, data, start_lua, end_lua)) end local function load_template(data, start_lua, end_lua) return assert(loadstring(compile_template_as_chunk(data, start_lua, end_lua), "=(load)")) end local function execute_template(template, environment, output) setfenv(template, environment)(output) end local function basic_environment(merge_global, environment) if not environment then environment = { } end if merge_global then ltp.merge_index(environment, _G) else environment.table = table end return environment end local function load_environment(env_files, merge_global) local environment = nil if env_files and #env_files > 0 then for i = 1,#env_files,1 do local efun = assert(loadfile(env_files[i])) if i > 1 then environment = ltp.merge_table(setfenv(efun, environment)(), environment) else environment = basic_environment(merge_global, efun()) end end else environment = basic_environment(merge_global) end return environment end local function read_template(template) return ((template == "-" and io.stdin:read("*a")) or ltp.read_all(template)) end local function render_template(template_data, start_lua, end_lua, environment) local rfun = load_template(template_data, start_lua, end_lua) local output = { } execute_template(rfun, environment, output) return table.concat(output) end local function execute_env_code(env_code, environment) for i = 1,#env_code do local fun, emsg = loadstring(env_code[i]) if fun then setfenv(fun, environment)() else error("error loading " .. env_code[i] .. "\n" .. emsg) end end end local function render(outfile, num_passes, template, merge_global, env_files, start_lua, end_lua, env_code) local data = assert(read_template(template), "error reading " .. template) local environment = load_environment(env_files, merge_global) execute_env_code(env_code, environment) if num_passes > 0 then for i = 1,num_passes do data = render_template(data, start_lua, end_lua, environment) end else -- Prevent an infinite loop by capping expansion to 100 times. num_passes = 1 repeat data = render_template(data, start_lua, end_lua, environment) num_passes = num_passes + 1 until data:find(start_lua, 1, true) == nil or num_passes >= 100 end outfile:write(data); end local function compile_as_function(outfile, template, start_lua, end_lua) local data = read_template(template) outfile:write(compile_template_as_function(data, start_lua, end_lua)) end local function compile(outfile, template, start_lua, end_lua) local data = read_template(template) outfile:write(compile_template(data, start_lua, end_lua)) end return ltp.merge_table( { compile_template_to_table = compile_template_to_table, compile_template_as_chunk = compile_template_as_chunk, compile_template_as_function = compile_template_as_function, compile_template = compile_template, load_template = load_template, execute_template = execute_template, basic_environment = basic_environment, load_environment = load_environment, render_template = render_template, execute_env_code = execute_env_code, render = render, compile_as_function = compile_as_function, compile = compile }, ltp )
gpl-2.0
wangtianhang/UnityLuaTest
toluaSnapshotTest/toluaRuntime/luajit-2.1/src/jit/v.lua
54
5783
---------------------------------------------------------------------------- -- Verbose mode of the LuaJIT compiler. -- -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module shows verbose information about the progress of the -- JIT compiler. It prints one line for each generated trace. This module -- is useful to see which code has been compiled or where the compiler -- punts and falls back to the interpreter. -- -- Example usage: -- -- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" -- luajit -jv=myapp.out myapp.lua -- -- Default output is to stderr. To redirect the output to a file, pass a -- filename as an argument (use '-' for stdout) or set the environment -- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the -- module is started. -- -- The output from the first example should look like this: -- -- [TRACE 1 (command line):1 loop] -- [TRACE 2 (1/3) (command line):1 -> 1] -- -- The first number in each line is the internal trace number. Next are -- the file name ('(command line)') and the line number (':1') where the -- trace has started. Side traces also show the parent trace number and -- the exit number where they are attached to in parentheses ('(1/3)'). -- An arrow at the end shows where the trace links to ('-> 1'), unless -- it loops to itself. -- -- In this case the inner loop gets hot and is traced first, generating -- a root trace. Then the last exit from the 1st trace gets hot, too, -- and triggers generation of the 2nd trace. The side trace follows the -- path along the outer loop and *around* the inner loop, back to its -- start, and then links to the 1st trace. Yes, this may seem unusual, -- if you know how traditional compilers work. Trace compilers are full -- of surprises like this -- have fun! :-) -- -- Aborted traces are shown like this: -- -- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] -- -- Don't worry -- trace aborts are quite common, even in programs which -- can be fully compiled. The compiler may retry several times until it -- finds a suitable trace. -- -- Of course this doesn't work with features that are not-yet-implemented -- (NYI error messages). The VM simply falls back to the interpreter. This -- may not matter at all if the particular trace is not very high up in -- the CPU usage profile. Oh, and the interpreter is quite fast, too. -- -- Also check out the -jdump module, which prints all the gory details. -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20100, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo local type, format = type, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. local active, out ------------------------------------------------------------------------------ local startloc, startex local function fmtfunc(func, pc) local fi = funcinfo(func, pc) if fi.loc then return fi.loc elseif fi.ffid then return vmdef.ffnames[fi.ffid] elseif fi.addr then return format("C:%x", fi.addr) else return "(?)" end end -- Format trace error message. local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end err = format(vmdef.traceerr[err], info) end return err end -- Dump trace states. local function dump_trace(what, tr, func, pc, otr, oex) if what == "start" then startloc = fmtfunc(func, pc) startex = otr and "("..otr.."/"..(oex == -1 and "stitch" or oex)..") " or "" else if what == "abort" then local loc = fmtfunc(func, pc) if loc ~= startloc then out:write(format("[TRACE --- %s%s -- %s at %s]\n", startex, startloc, fmterr(otr, oex), loc)) else out:write(format("[TRACE --- %s%s -- %s]\n", startex, startloc, fmterr(otr, oex))) end elseif what == "stop" then local info = traceinfo(tr) local link, ltype = info.link, info.linktype if ltype == "interpreter" then out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", tr, startex, startloc)) elseif ltype == "stitch" then out:write(format("[TRACE %3s %s%s %s %s]\n", tr, startex, startloc, ltype, fmtfunc(func, pc))) elseif link == tr or link == 0 then out:write(format("[TRACE %3s %s%s %s]\n", tr, startex, startloc, ltype)) elseif ltype == "root" then out:write(format("[TRACE %3s %s%s -> %d]\n", tr, startex, startloc, link)) else out:write(format("[TRACE %3s %s%s -> %d %s]\n", tr, startex, startloc, link, ltype)) end else out:write(format("[TRACE %s]\n", what)) end out:flush() end end ------------------------------------------------------------------------------ -- Detach dump handlers. local function dumpoff() if active then active = false jit.attach(dump_trace) if out and out ~= stdout and out ~= stderr then out:close() end out = nil end end -- Open the output file and attach dump handlers. local function dumpon(outfile) if active then dumpoff() end if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stderr end jit.attach(dump_trace, "trace") active = true end -- Public module functions. return { on = dumpon, off = dumpoff, start = dumpon -- For -j command line option. }
mit
saydulk/newfies-dialer
lua/playarea/fsm.lua
15
7426
-- ========================================================================================== -- -- Finite State Machine Class for Lua 5.1 & Corona SDK -- -- Written by Erik Cornelisse, inspired by Luiz Henrique de Figueiredo -- E-mail: e.cornelisse@gmail.com -- -- Version 1.0 April 27, 2011 -- -- Class is MIT Licensed -- Copyright (c) 2011 Erik Cornelisse -- -- Feel free to change but please send new versions, improvements or -- new features to me and help us to make it better. -- -- ========================================================================================== --[[ A design pattern for doing finite state machines (FSMs) in Lua. Based on a very appreciated contribution of Luiz Henrique de Figueiredo Original code from http://lua-users.org/wiki/FiniteStateMachine The FSM is described with: old_state, event, new_state and action. One easy way to do this in Lua would be to create a table in exactly the form above: yourStateTransitionTable = { {state1, event1, state2, action1}, {state1, event2, state3, action2}, ... } The function FSM takes the simple syntax above and creates tables for (state, event) pairs with fields (action, new): function FSM(yourStateTransitionTable) local stt = {} for _,v in ipairs(t) do local old, event, new, action = v[1], v[2], v[3], v[4] if stt[old] == nil then a[old] = {} end stt[old][event] = {new = new, action = action} end return stt end Note that this scheme works for states and events of any type: number, string, functions, tables, anything. Such is the power of associate arrays. However, the double array stt[old][event] caused a problem for event = nil Instead a single array is used, constructed as stt[state .. SEPARATOR .. event] Where SEPARATOR is a constant and defined as '.' Three special state transitions are added to the original code: - any state but a specific event - any event but a specific state - unknown state-event combination to be used for exception handling The any state and event are defined by the ANY constant, defined as '*' The unknown state-event is defined as the combination of ANY.ANY (*.*) A default exception handler for unknown state-event combinations is provided and therefore a specification a your own exception handling is optional. After creating a new FSM, the initial state is set to the first defined state in your state transition table. With add(t) and delete(t), new state transition can be added and removed later. A DEBUG-like method called silent is included to prevent wise-guy remarks about things you shouldn't be doing. USAGE EXAMPLES: ------------------------------------------------------------------------------- FSM = require "fsm" function action1() print("Performing action 1") end function action2() print("Performing action 2") end -- Define your state transitions here local myStateTransitionTable = { {"state1", "event1", "state2", action1}, {"state2", "event2", "state3", action2}, {"*", "event3", "state2", action1}, -- for any state {"*", "*", "state2", action2} -- exception handler } -- Create your finite state machine fsm = FSM.new(myStateTransitionTable) -- Use your finite state machine -- which starts by default with the first defined state print("Current FSM state: " .. fsm:get()) -- Or you can set another state fsm:set("state2") print("Current FSM state: " .. fsm:get()) -- Resond on "event" and last set "state" fsm:fire("event2") print("Current FSM state: " .. fsm:get()) Output: ------- Current FSM state: state1 Current FSM state: state2 Performing action 2 Current FSM state: state3 REMARKS: ------------------------------------------------------------------------------- Sub-states are not supported by additional methods to keep the code simple. If you need sub-states, you can create them as 'state.substate' directly. A specific remove method is not provided because I didn't need one (I think) But feel free to implement one yourself :-) One more thing, did I already mentioned that I am new to Lua? Well, I learn a lot of other examples, so do not forget yours. CONCLUSION: ------------------------------------------------------------------------------- A small amount of code is required to use the power of a Finite State Machine. I wrote this code to implement generic graphical objects where the presentation and behaviour of the objects can be specified by using state-transition tables. This resulted in less code (and less bugs), a higher modularity and above all a reduction of the complexity. Finite state machines can be used to force (at least parts of) your code into deterministic behaviour. Have fun !! --]] --MODULE CODE ------------------------------------------------------------------------------- module(..., package.seeall) -- FSM CONSTANTS -------------------------------------------------------------- SEPARATOR = '.' ANY = '*' ANYSTATE = ANY .. SEPARATOR ANYEVENT = SEPARATOR .. ANY UNKNOWN = ANYSTATE .. ANY function new(t) local self = {} -- ATTRIBUTES ------------------------------------------------------------- local state = t[1][1] -- current state, default the first one local stt = {} -- state transition table local str = "" -- <state><SEPARATOR><event> combination local silence = false -- use silent() for whisper mode -- METHODS ---------------------------------------------------------------- -- some getters and setters function self:set(s) state = s end function self:get() return state end function self:silent() silence = true end -- default exception handling local function exception() if silence == false then print("FSM: unknown combination: " .. str) end return false end -- respond based on current state and event function self:fire(event) local act = stt[state .. SEPARATOR .. event] -- raise exception for unknown state-event combination if act == nil then -- search for wildcard "states" for this event act = stt[ANYSTATE .. event] -- if still not a match than check any event if act == nil then -- check if there is a wildcard event act = stt[state .. ANYEVENT] if act == nil then act = stt[UNKNOWN]; str = state .. SEPARATOR .. event end end end -- set next state as current state state = act.newState return act.action() end -- add new state transitions to the FSM function self:add(t) for _,v in ipairs(t) do local oldState, event, newState, action = v[1], v[2], v[3], v[4] stt[oldState .. SEPARATOR .. event] = {newState = newState, action = action} end return #t -- the requested number of state-transitions to be added end -- remove state transitions from the FSM function self:delete(t) for _,v in ipairs(t) do local oldState, event = v[1], v[2] if oldState == ANY and event == ANY then if not silence then print( "FSM: you should not delete the exception handler" ) print( "FSM: but assign another exception action" ) end -- assign default exception handler but stay in current state stt[exception] = {newState = state, action = exception} else stt[oldState .. SEPARATOR .. event] = nil end end return #t -- the requested number of state-transitions to be deleted end -- initalise state transition table stt[UNKNOWN] = {newState = state, action = exception} self:add(t) -- return FSM methods return self end
mpl-2.0
jzbontar/nn
Euclidean.lua
24
5711
local Euclidean, parent = torch.class('nn.Euclidean', 'nn.Module') function Euclidean:__init(inputSize,outputSize) parent.__init(self) self.weight = torch.Tensor(inputSize,outputSize) self.gradWeight = torch.Tensor(inputSize,outputSize) -- state self.gradInput:resize(inputSize) self.output:resize(outputSize) self.fastBackward = true self:reset() end function Euclidean:reset(stdv) if stdv then stdv = stdv * math.sqrt(3) else stdv = 1./math.sqrt(self.weight:size(1)) end if nn.oldSeed then for i=1,self.weight:size(2) do self.weight:select(2, i):apply(function() return torch.uniform(-stdv, stdv) end) end else self.weight:uniform(-stdv, stdv) end end local function view(res, src, ...) local args = {...} if src:isContiguous() then res:view(src, table.unpack(args)) else res:reshape(src, table.unpack(args)) end end function Euclidean:updateOutput(input) -- lazy initialize buffers self._input = self._input or input.new() self._weight = self._weight or self.weight.new() self._expand = self._expand or self.output.new() self._expand2 = self._expand2 or self.output.new() self._repeat = self._repeat or self.output.new() self._repeat2 = self._repeat2 or self.output.new() local inputSize, outputSize = self.weight:size(1), self.weight:size(2) -- y_j = || w_j - x || = || x - w_j || if input:dim() == 1 then view(self._input, input, inputSize, 1) self._expand:expandAs(self._input, self.weight) self._repeat:resizeAs(self._expand):copy(self._expand) self._repeat:add(-1, self.weight) self.output:norm(self._repeat, 2, 1) self.output:resize(outputSize) elseif input:dim() == 2 then local batchSize = input:size(1) view(self._input, input, batchSize, inputSize, 1) self._expand:expand(self._input, batchSize, inputSize, outputSize) -- make the expanded tensor contiguous (requires lots of memory) self._repeat:resizeAs(self._expand):copy(self._expand) self._weight:view(self.weight, 1, inputSize, outputSize) self._expand2:expandAs(self._weight, self._repeat) if torch.type(input) == 'torch.CudaTensor' then -- requires lots of memory, but minimizes cudaMallocs and loops self._repeat2:resizeAs(self._expand2):copy(self._expand2) self._repeat:add(-1, self._repeat2) else self._repeat:add(-1, self._expand2) end self.output:norm(self._repeat, 2, 2) self.output:resize(batchSize, outputSize) else error"1D or 2D input expected" end return self.output end function Euclidean:updateGradInput(input, gradOutput) if not self.gradInput then return end self._div = self._div or input.new() self._output = self._output or self.output.new() self._gradOutput = self._gradOutput or input.new() self._expand3 = self._expand3 or input.new() if not self.fastBackward then self:updateOutput(input) end local inputSize, outputSize = self.weight:size(1), self.weight:size(2) --[[ dy_j -2 * (w_j - x) x - w_j ---- = --------------- = ------- dx 2 || w_j - x || y_j --]] -- to prevent div by zero (NaN) bugs self._output:resizeAs(self.output):copy(self.output):add(0.0000001) view(self._gradOutput, gradOutput, gradOutput:size()) self._div:cdiv(gradOutput, self._output) if input:dim() == 1 then self._div:resize(1, outputSize) self._expand3:expandAs(self._div, self.weight) if torch.type(input) == 'torch.CudaTensor' then self._repeat2:resizeAs(self._expand3):copy(self._expand3) self._repeat2:cmul(self._repeat) else self._repeat2:cmul(self._repeat, self._expand3) end self.gradInput:sum(self._repeat2, 2) self.gradInput:resizeAs(input) elseif input:dim() == 2 then local batchSize = input:size(1) self._div:resize(batchSize, 1, outputSize) self._expand3:expand(self._div, batchSize, inputSize, outputSize) if torch.type(input) == 'torch.CudaTensor' then self._repeat2:resizeAs(self._expand3):copy(self._expand3) self._repeat2:cmul(self._repeat) else self._repeat2:cmul(self._repeat, self._expand3) end self.gradInput:sum(self._repeat2, 3) self.gradInput:resizeAs(input) else error"1D or 2D input expected" end return self.gradInput end function Euclidean:accGradParameters(input, gradOutput, scale) local inputSize, outputSize = self.weight:size(1), self.weight:size(2) scale = scale or 1 --[[ dy_j 2 * (w_j - x) w_j - x ---- = --------------- = ------- dw_j 2 || w_j - x || y_j --]] -- assumes a preceding call to updateGradInput if input:dim() == 1 then self.gradWeight:add(-scale, self._repeat2) elseif input:dim() == 2 then self._sum = self._sum or input.new() self._sum:sum(self._repeat2, 1) self._sum:resize(inputSize, outputSize) self.gradWeight:add(-scale, self._sum) else error"1D or 2D input expected" end end function Euclidean:type(type, tensorCache) if type then -- prevent premature memory allocations self._input = nil self._output = nil self._gradOutput = nil self._weight = nil self._div = nil self._sum = nil self._expand = nil self._expand2 = nil self._expand3 = nil self._repeat = nil self._repeat2 = nil end return parent.type(self, type, tensorCache) end
bsd-3-clause
wangtianhang/UnityLuaTest
toluaSnapshotTest/toluaUnityProject/Assets/ToLua/Lua/UnityEngine/Ray.lua
6
1419
-------------------------------------------------------------------------------- -- Copyright (c) 2015 - 2016 , 蒙占志(topameng) topameng@gmail.com -- All rights reserved. -- Use, modification and distribution are subject to the "MIT License" -------------------------------------------------------------------------------- local rawget = rawget local setmetatable = setmetatable local Vector3 = Vector3 local Ray = { direction = Vector3.zero, origin = Vector3.zero, } local get = tolua.initget(Ray) Ray.__index = function(t,k) local var = rawget(Ray, k) if var == nil then var = rawget(get, k) if var ~= nil then return var(t) end end return var end Ray.__call = function(t, direction, origin) return Ray.New(direction, origin) end function Ray.New(direction, origin) local ray = {} ray.direction = direction:Normalize() ray.origin = origin setmetatable(ray, Ray) return ray end function Ray:GetPoint(distance) local dir = self.direction * distance dir:Add(self.origin) return dir end function Ray:Get() local o = self.origin local d = self.direction return o.x, o.y, o.z, d.x, d.y, d.z end Ray.__tostring = function(self) return string.format("Origin:(%f,%f,%f),Dir:(%f,%f, %f)", self.origin.x, self.origin.y, self.origin.z, self.direction.x, self.direction.y, self.direction.z) end UnityEngine.Ray = Ray setmetatable(Ray, Ray) return Ray
mit
flexiti/nodemcu-firmware
lua_examples/u8glib/u8g_graphics_test.lua
43
4007
-- setup I2c and connect display function init_i2c_display() -- SDA and SCL can be assigned freely to available GPIOs local sda = 5 -- GPIO14 local scl = 6 -- GPIO12 local sla = 0x3c i2c.setup(0, sda, scl, i2c.SLOW) disp = u8g.ssd1306_128x64_i2c(sla) end -- setup SPI and connect display function init_spi_display() -- Hardware SPI CLK = GPIO14 -- Hardware SPI MOSI = GPIO13 -- Hardware SPI MISO = GPIO12 (not used) -- CS, D/C, and RES can be assigned freely to available GPIOs local cs = 8 -- GPIO15, pull-down 10k to GND local dc = 4 -- GPIO2 local res = 0 -- GPIO16 spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0) disp = u8g.ssd1306_128x64_spi(cs, dc, res) end -- graphic test components function prepare() disp:setFont(u8g.font_6x10) disp:setFontRefHeightExtendedText() disp:setDefaultForegroundColor() disp:setFontPosTop() end function box_frame(a) disp:drawStr(0, 0, "drawBox") disp:drawBox(5, 10, 20, 10) disp:drawBox(10+a, 15, 30, 7) disp:drawStr(0, 30, "drawFrame") disp:drawFrame(5, 10+30, 20, 10) disp:drawFrame(10+a, 15+30, 30, 7) end function disc_circle(a) disp:drawStr(0, 0, "drawDisc") disp:drawDisc(10, 18, 9) disp:drawDisc(24+a, 16, 7) disp:drawStr(0, 30, "drawCircle") disp:drawCircle(10, 18+30, 9) disp:drawCircle(24+a, 16+30, 7) end function r_frame(a) disp:drawStr(0, 0, "drawRFrame/Box") disp:drawRFrame(5, 10, 40, 30, a+1) disp:drawRBox(50, 10, 25, 40, a+1) end function stringtest(a) disp:drawStr(30+a, 31, " 0") disp:drawStr90(30, 31+a, " 90") disp:drawStr180(30-a, 31, " 180") disp:drawStr270(30, 31-a, " 270") end function line(a) disp:drawStr(0, 0, "drawLine") disp:drawLine(7+a, 10, 40, 55) disp:drawLine(7+a*2, 10, 60, 55) disp:drawLine(7+a*3, 10, 80, 55) disp:drawLine(7+a*4, 10, 100, 55) end function triangle(a) local offset = a disp:drawStr(0, 0, "drawTriangle") disp:drawTriangle(14,7, 45,30, 10,40) disp:drawTriangle(14+offset,7-offset, 45+offset,30-offset, 57+offset,10-offset) disp:drawTriangle(57+offset*2,10, 45+offset*2,30, 86+offset*2,53) disp:drawTriangle(10+offset,40+offset, 45+offset,30+offset, 86+offset,53+offset) end function ascii_1() local x, y, s disp:drawStr(0, 0, "ASCII page 1") for y = 0, 5, 1 do for x = 0, 15, 1 do s = y*16 + x + 32 disp:drawStr(x*7, y*10+10, string.char(s)) end end end function extra_page(a) disp:drawStr(0, 12, "setScale2x2") disp:setScale2x2() disp:drawStr(0, 6+a, "setScale2x2") disp:undoScale() end -- the draw() routine function draw(draw_state) local component = bit.rshift(draw_state, 3) prepare() if (component == 0) then box_frame(bit.band(draw_state, 7)) elseif (component == 1) then disc_circle(bit.band(draw_state, 7)) elseif (component == 2) then r_frame(bit.band(draw_state, 7)) elseif (component == 3) then stringtest(bit.band(draw_state, 7)) elseif (component == 4) then line(bit.band(draw_state, 7)) elseif (component == 5) then triangle(bit.band(draw_state, 7)) elseif (component == 6) then ascii_1() elseif (component == 7) then extra_page(bit.band(draw_state, 7)) end end function graphics_test(delay) print("--- Starting Graphics Test ---") -- cycle through all components local draw_state for draw_state = 0, 7 + 8*8, 1 do disp:firstPage() repeat draw(draw_state) until disp:nextPage() == false --print(node.heap()) tmr.delay(delay) -- re-trigger Watchdog! tmr.wdclr() end print("--- Graphics Test done ---") end --init_i2c_display() init_spi_display() graphics_test(50000)
mit
jzbontar/nn
SelectTable.lua
24
1393
local SelectTable, parent = torch.class('nn.SelectTable', 'nn.Module') function SelectTable:__init(index) parent.__init(self) self.index = index self.gradInput = {} end function SelectTable:updateOutput(input) assert(math.abs(self.index) <= #input, "arg 1 table idx out of range") if self.index < 0 then self.output = input[#input + self.index + 1] else self.output = input[self.index] end return self.output end local function zeroTableCopy(t1, t2) for k, v in pairs(t2) do if (torch.type(v) == "table") then t1[k] = zeroTableCopy(t1[k] or {}, t2[k]) else if not t1[k] then t1[k] = v:clone():zero() else local tensor = t1[k] if not tensor:isSameSizeAs(v) then t1[k]:resizeAs(v) t1[k]:zero() end end end end return t1 end function SelectTable:updateGradInput(input, gradOutput) if self.index < 0 then self.gradInput[#input + self.index + 1] = gradOutput else self.gradInput[self.index] = gradOutput end zeroTableCopy(self.gradInput, input) for i=#input+1, #self.gradInput do self.gradInput[i] = nil end return self.gradInput end function SelectTable:type(type, tensorCache) self.gradInput = {} self.output = {} return parent.type(self, type, tensorCache) end
bsd-3-clause
nobie/sesame_fw
feeds/luci/applications/luci-asterisk/dist/usr/lib/lua/luci/model/cbi/asterisk-voice.lua
80
1493
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- cbimap = Map("asterisk", "asterisk", "") voicegeneral = cbimap:section(TypedSection, "voicegeneral", "Voicemail general options", "") serveremail = voicegeneral:option(Value, "serveremail", "From Email address of server", "") voicemail = cbimap:section(TypedSection, "voicemail", "Voice Mail boxes", "") voicemail.addremove = true attach = voicemail:option(Flag, "attach", "Email contains attachment", "") attach.rmempty = true email = voicemail:option(Value, "email", "Email", "") email.rmempty = true name = voicemail:option(Value, "name", "Display Name", "") name.rmempty = true password = voicemail:option(Value, "password", "Password", "") password.rmempty = true zone = voicemail:option(ListValue, "zone", "Voice Zone", "") cbimap.uci:foreach( "asterisk", "voicezone", function(s) zone:value(s['.name']) end ) voicezone = cbimap:section(TypedSection, "voicezone", "Voice Zone settings", "") voicezone.addremove = true message = voicezone:option(Value, "message", "Message Format", "") message.rmempty = true zone = voicezone:option(Value, "zone", "Time Zone", "") zone.rmempty = true return cbimap
gpl-2.0
litnimax/luci
applications/luci-asterisk/luasrc/model/cbi/asterisk-voice.lua
80
1493
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- cbimap = Map("asterisk", "asterisk", "") voicegeneral = cbimap:section(TypedSection, "voicegeneral", "Voicemail general options", "") serveremail = voicegeneral:option(Value, "serveremail", "From Email address of server", "") voicemail = cbimap:section(TypedSection, "voicemail", "Voice Mail boxes", "") voicemail.addremove = true attach = voicemail:option(Flag, "attach", "Email contains attachment", "") attach.rmempty = true email = voicemail:option(Value, "email", "Email", "") email.rmempty = true name = voicemail:option(Value, "name", "Display Name", "") name.rmempty = true password = voicemail:option(Value, "password", "Password", "") password.rmempty = true zone = voicemail:option(ListValue, "zone", "Voice Zone", "") cbimap.uci:foreach( "asterisk", "voicezone", function(s) zone:value(s['.name']) end ) voicezone = cbimap:section(TypedSection, "voicezone", "Voice Zone settings", "") voicezone.addremove = true message = voicezone:option(Value, "message", "Message Format", "") message.rmempty = true zone = voicezone:option(Value, "zone", "Time Zone", "") zone.rmempty = true return cbimap
apache-2.0
miralireza2/gpf
plugins/minecraft.lua
624
2605
local usage = { "!mine [ip]: Searches Minecraft server on specified ip and sends info. Default port: 25565", "!mine [ip] [port]: Searches Minecraft server on specified ip and port and sends info.", } local ltn12 = require "ltn12" local function mineSearch(ip, port, receiver) --25565 local responseText = "" local api = "https://api.syfaro.net/server/status" local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true" local http = require("socket.http") local respbody = {} local body, code, headers, status = http.request{ url = api..parameters, method = "GET", redirect = true, sink = ltn12.sink.table(respbody) } local body = table.concat(respbody) if (status == nil) then return "ERROR: status = nil" end if code ~=200 then return "ERROR: "..code..". Status: "..status end local jsonData = json:decode(body) responseText = responseText..ip..":"..port.." ->\n" if (jsonData.motd ~= nil) then local tempMotd = "" tempMotd = jsonData.motd:gsub('%§.', '') if (jsonData.motd ~= nil) then responseText = responseText.." Motd: "..tempMotd.."\n" end end if (jsonData.online ~= nil) then responseText = responseText.." Online: "..tostring(jsonData.online).."\n" end if (jsonData.players ~= nil) then if (jsonData.players.max ~= nil) then responseText = responseText.." Max Players: "..jsonData.players.max.."\n" end if (jsonData.players.now ~= nil) then responseText = responseText.." Players online: "..jsonData.players.now.."\n" end if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then responseText = responseText.." Players: "..table.concat(jsonData.players.sample, ", ").."\n" end end if (jsonData.favicon ~= nil and false) then --send_photo(receiver, jsonData.favicon) --(decode base64 and send) end return responseText end local function parseText(chat, text) if (text == nil or text == "!mine") then return usage end ip, port = string.match(text, "^!mine (.-) (.*)$") if (ip ~= nil and port ~= nil) then return mineSearch(ip, port, chat) end local ip = string.match(text, "^!mine (.*)$") if (ip ~= nil) then return mineSearch(ip, "25565", chat) end return "ERROR: no input ip?" end local function run(msg, matches) local chat_id = tostring(msg.to.id) local result = parseText(chat_id, msg.text) return result end return { description = "Searches Minecraft server and sends info", usage = usage, patterns = { "^!mine (.*)$" }, run = run }
gpl-2.0
alirezafodaji/tele-Avast
plugins/location.lua
93
1704
-- Implement a command !loc [area] which uses -- the static map API to get a location image -- Not sure if this is the proper way -- Intent: get_latlong is in time.lua, we need it here -- loadfile "time.lua" -- Globals -- If you have a google api key for the geocoding/timezone api do local api_key = nil local base_api = "https://maps.googleapis.com/maps/api" function get_staticmap(area) local api = base_api .. "/staticmap?" -- Get a sense of scale local lat,lng,acc,types = get_latlong(area) local scale = types[1] if scale=="locality" then zoom=8 elseif scale=="country" then zoom=4 else zoom = 13 end local parameters = "size=600x300" .. "&zoom=" .. zoom .. "&center=" .. URL.escape(area) .. "&markers=color:red"..URL.escape("|"..area) if api_key ~=nil and api_key ~= "" then parameters = parameters .. "&key="..api_key end return lat, lng, api..parameters end function run(msg, matches) local receiver = get_receiver(msg) local lat,lng,url = get_staticmap(matches[1]) -- Send the actual location, is a google maps link send_location(receiver, lat, lng, ok_cb, false) -- Send a picture of the map, which takes scale into account send_photo_from_url(receiver, url) -- Return a link to the google maps stuff is now not needed anymore return nil end return { description = "Gets information about a location, maplink and overview", usage = "!loc (location): Gets information about a location, maplink and overview", patterns = {"^!loc (.*)$"}, run = run } end --Copyright and edit; @behroozyaghi --Persian Translate; @behroozyaghi --ch : @nod32team --کپی بدون ذکر منبع حرام است
gpl-2.0
flike/Atlas
lib/histogram.lua
40
5165
--[[ $%BEGINLICENSE%$ Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $%ENDLICENSE%$ --]] local tokenizer = require("proxy.tokenizer") local parser = require("proxy.parser") local commands = require("proxy.commands") local auto_config = require("proxy.auto-config") -- init global counters if not proxy.global.config.histogram then proxy.global.config.histogram = { collect_queries = true, collect_tables = true } end -- init query counters if not proxy.global.norm_queries then proxy.global.norm_queries = { } end -- init table-usage if not proxy.global.tables then proxy.global.tables = { } end function read_query(packet) local cmd = commands.parse(packet) local r = auto_config.handle(cmd) if r then return r end if cmd.type == proxy.COM_QUERY then local tokens = assert(tokenizer.tokenize(cmd.query)) local norm_query = tokenizer.normalize(tokens) -- print("normalized query: " .. norm_query) if norm_query == "SELECT * FROM `histogram` . `queries` " then proxy.response = { type = proxy.MYSQLD_PACKET_OK, resultset = { fields = { { type = proxy.MYSQL_TYPE_STRING, name = "query" }, { type = proxy.MYSQL_TYPE_LONG, name = "count" }, { type = proxy.MYSQL_TYPE_LONG, name = "max_query_time" }, { type = proxy.MYSQL_TYPE_FLOAT, name = "avg_query_time" }, } } } local rows = {} if proxy.global.norm_queries then for k, v in pairs(proxy.global.norm_queries) do rows[#rows + 1] = { k, v.count, v.max_query_time, v.avg_query_time, } end end proxy.response.resultset.rows = rows return proxy.PROXY_SEND_RESULT elseif norm_query == "DELETE FROM `histogram` . `queries` " then proxy.response = { type = proxy.MYSQLD_PACKET_OK, } proxy.global.norm_queries = {} return proxy.PROXY_SEND_RESULT elseif norm_query == "SELECT * FROM `histogram` . `tables` " then proxy.response = { type = proxy.MYSQLD_PACKET_OK, resultset = { fields = { { type = proxy.MYSQL_TYPE_STRING, name = "table" }, { type = proxy.MYSQL_TYPE_LONG, name = "reads" }, { type = proxy.MYSQL_TYPE_LONG, name = "writes" }, } } } local rows = {} if proxy.global.tables then for k, v in pairs(proxy.global.tables) do rows[#rows + 1] = { k, v.reads, v.writes, } end end proxy.response.resultset.rows = rows return proxy.PROXY_SEND_RESULT elseif norm_query == "DELETE FROM `histogram` . `tables` " then proxy.response = { type = proxy.MYSQLD_PACKET_OK, } proxy.global.tables = {} return proxy.PROXY_SEND_RESULT end if proxy.global.config.histogram.collect_queries or proxy.global.config.histogram.collect_tables then proxy.queries:append(1, packet) return proxy.PROXY_SEND_QUERY end end end function read_query_result(inj) local cmd = commands.parse(inj.query) if cmd.type == proxy.COM_QUERY then local tokens = assert(tokenizer.tokenize(cmd.query)) local norm_query = tokenizer.normalize(tokens) if proxy.global.config.histogram.collect_queries then if not proxy.global.norm_queries[norm_query] then proxy.global.norm_queries[norm_query] = { count = 0, max_query_time = 0, avg_query_time = 0 } end -- set new max if necessary if inj.query_time > proxy.global.norm_queries[norm_query].max_query_time then proxy.global.norm_queries[norm_query].max_query_time = inj.query_time end -- build rolling average proxy.global.norm_queries[norm_query].avg_query_time = ((proxy.global.norm_queries[norm_query].avg_query_time * proxy.global.norm_queries[norm_query].count) + inj.query_time) / (proxy.global.norm_queries[norm_query].count + 1) proxy.global.norm_queries[norm_query].count = proxy.global.norm_queries[norm_query].count + 1 end if proxy.global.config.histogram.collect_tables then -- extract the tables from the queries tables = parser.get_tables(tokens) for table, qtype in pairs(tables) do if not proxy.global.tables[table] then proxy.global.tables[table] = { reads = 0, writes = 0 } end if qtype == "read" then proxy.global.tables[table].reads = proxy.global.tables[table].reads + 1 else proxy.global.tables[table].writes = proxy.global.tables[table].writes + 1 end end end end end
gpl-2.0
alirezafodaji/tele-Avast
plugins/boobs.lua
90
1731
do -- Recursive function local function getRandomButts(attempt) attempt = attempt or 0 attempt = attempt + 1 local res,status = http.request("http://api.obutts.ru/noise/1") if status ~= 200 then return nil end local data = json:decode(res)[1] -- The OpenBoobs API sometimes returns an empty array if not data and attempt <= 3 then print('Cannot get that butts, trying another one...') return getRandomButts(attempt) end return 'http://media.obutts.ru/' .. data.preview end local function getRandomBoobs(attempt) attempt = attempt or 0 attempt = attempt + 1 local res,status = http.request("http://api.oboobs.ru/noise/1") if status ~= 200 then return nil end local data = json:decode(res)[1] -- The OpenBoobs API sometimes returns an empty array if not data and attempt < 10 then print('Cannot get that boobs, trying another one...') return getRandomBoobs(attempt) end return 'http://media.oboobs.ru/' .. data.preview end local function run(msg, matches) local url = nil if matches[1] == "!boobs" then url = getRandomBoobs() end if matches[1] == "!butts" then url = getRandomButts() end if url ~= nil then local receiver = get_receiver(msg) send_photo_from_url(receiver, url) else return 'Error getting boobs/butts for you, please try again later.' end end return { description = "Gets a random boobs or butts pic", usage = { "!boobs: Get a boobs NSFW image. 🔞", "!butts: Get a butts NSFW image. 🔞" }, patterns = { "^!boobs$", "^!butts$" }, run = run } end --Copyright; @behroozyaghi --Persian Translate; @behroozyaghi --ch : @nod32team --کپی بدون ذکر منبع حرام است
gpl-2.0
cecile/Cecile_QuickLaunch
src/Cecile_QuickLaunch/modules/utils/debug.lua
2
7522
---------------------------------------------------------------------------------------------------- -- debug module, based on LibDebug-1.0.lua by Alkis & Evlogimenos -- using lib debug will make all add-ons debug lines to show in the same window. --get the engine and create the module local Engine = select(2,...); local mod = Engine.AddOn:NewModule("debug"); --get the locale local L=Engine.Locale; --module defaults mod.Defaults = { profile = { output = false, }, }; --module options table mod.Options = { order = 99, type = "group", name = L["DEV_SETTINGS"], cmdInline = true, args = { debug = { order = 1, type = "toggle", name = L["DEBUGGING"], desc = L["DEBUGGING_DESC"], get = function() return mod.isDebugging; end, set = function( _ , value ) mod:EnableDebugging(value); mod:Show(value); end, }, } }; --load profile settings function mod:LoadProfileSettings() local outputDebug = Engine.Profile.debug.output; self:EnableDebugging(outputDebug); self:Show(outputDebug); end --save profile settings function mod:SaveProfileSettings() Engine.Profile.debug.output = self.isDebugging; end ---scroll the window with mouse wheel function mod.ScrollingFunction(self, arg) --check if we scroll down or up and if shift is down if arg > 0 then if _G.IsShiftKeyDown() then self:ScrollToTop(); else self:ScrollUp(); end elseif arg < 0 then if _G.IsShiftKeyDown() then self:ScrollToBottom(); else self:ScrollDown(); end end end --initialize the module function mod:OnInitialize() --set the call for our module local mt = getmetatable(self) or {}; mt.__call = self.DebugStub; setmetatable(self, mt); --module frame mod.frame = _G.CreateFrame("Frame", Engine.Name.."_DBG_Frame", _G.UIParent, BackdropTemplateMixin and "BackdropTemplate"); local frame = self.frame; --main window frame:EnableMouse(); frame:SetMinResize(300, 100); frame:SetWidth(400); frame:SetHeight(400); frame:SetPoint("CENTER", _G.UIParent); frame:SetFrameStrata("TOOLTIP"); frame:SetBackdrop( { bgFile = "Interface\\Tooltips\\ChatBubble-Background", edgeFile = "Interface\\Tooltips\\ChatBubble-BackDrop", tile = true, tileSize = 16, edgeSize = 16, insets = { left=16, right=16, top=16, bottom=16 } }) frame:SetBackdropColor(0, 0, 0, 1); -- The title bar/drag bar. frame:SetMovable(true); frame:SetClampedToScreen(true); frame.title = _G.CreateFrame("Button", nil, frame); frame.title:SetNormalFontObject("GameFontNormal"); frame.title:SetText(Engine.Name.." Debug"); frame.title:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -8); frame.title:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -8, -8); frame.title:SetHeight(8); frame.title:SetHighlightTexture( "Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar"); --move main window frame.title:SetScript("OnMouseDown",function (object) object:GetParent():StartMoving(); end); frame.title:SetScript("OnMouseUp",function (object) object:GetParent():StopMovingOrSizing(); end); -- The sizing button. frame:SetResizable(true); frame.sizer = _G.CreateFrame("Button", nil, frame); frame.sizer:SetHeight(16); frame.sizer:SetWidth(16); frame.sizer:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT"); --change main window size frame.sizer:SetScript("OnMouseDown",function (object) object:GetParent():StartSizing("BOTTOMRIGHT"); end); frame.sizer:SetScript("OnMouseUp",function (object) object:GetParent():StopMovingOrSizing(); end); local line1 = frame.sizer:CreateTexture(nil, "BACKGROUND"); line1:SetWidth(14); line1:SetHeight(14); line1:SetPoint("BOTTOMRIGHT", -8, 8); line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border"); local x = 0.1 * 14/17; line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5); local line2 = frame.sizer:CreateTexture(nil, "BACKGROUND"); line2:SetWidth(8); line2:SetHeight(8); line2:SetPoint("BOTTOMRIGHT", -8, 8); line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border"); x = 0.1 * 8/17; line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5); frame.bottom = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall"); frame.bottom:SetJustifyH("LEFT"); frame.bottom:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 8, 8); frame.bottom:SetPoint("BOTTOMRIGHT", frame.sizer); frame.bottom:SetHeight(8); frame.bottom:SetText(L["DEBUG_WINDOW_HELP"]); -- The scrolling message frame with all the debug info. frame.msg = _G.CreateFrame("ScrollingMessageFrame", nil, frame); frame.msg:SetPoint("TOPLEFT", frame.title, "BOTTOMLEFT"); frame.msg:SetPoint("TOPRIGHT", frame.title, "BOTTOMRIGHT"); frame.msg:SetPoint("BOTTOM", frame.bottom, "TOP", 0, 8); frame.msg:SetMaxLines(10000); frame.msg:SetFading(false); frame.msg:SetFontObject(_G.ChatFontNormal); frame.msg:SetJustifyH("LEFT"); frame.msg:EnableMouseWheel(true); -- Hook scrolling to scroll up down with mouse wheel. shift mouse wheel -- scroll all the way to the top/bottom. frame.msg:SetScript("OnMouseWheel", self.ScrollingFunction); self.isDebugging = false; frame:Hide(); --load profile settings mod:LoadProfileSettings(); end --stub default function when we are not debugging function mod.DebugStub() end --get the time function mod.GetTimeShort() return _G.GetTime() - mod.start_time; end --get the caller for this module function mod.GetCaller() ---get the stack trace local trace = _G.debugstack(3, 1, 0); --get the add-on name local addon = trace:match("AddOns\\([^\\]+)\\"); if(addon) then addon = addon..":"; else addon = ""; end --return the caller, including add-on name if we found it return addon..trace:match("([^\\]-): in function") or trace; end --write to the debug window function mod:Debug(fmt, ...) if (fmt==nil) then self.frame.msg:AddMessage(string.format("%6.3f (%s): nil", self.GetTimeShort(), self.GetCaller())); else self.frame.msg:AddMessage(string.format("%6.3f (%s): "..fmt, self.GetTimeShort(), self.GetCaller(), ...)); end end --returns if the module its debugging function mod:IsDebugging() return self.isDebugging; end --enable/disable debugging function mod:EnableDebugging(val) --change the default function local mt = getmetatable(self) if val == false then mt.__call = self.DebugStub; self.isDebugging = false; else mt.__call = self.Debug; self.isDebugging = true; self.start_time = _G.GetTime(); end --save profile settings self:SaveProfileSettings(); end --show/hide the main window function mod:Show(value) if(value) then if not self.frame:IsShown() then self.frame:Show(); end else if self.frame:IsShown() then self.frame:Hide(); end end end --profile has change function mod.OnProfileChanged() --load profile settings mod:LoadProfileSettings(); end --handle commands function mod.handleCommand(args) --has this module handle the command? local handleIt = false; --if the command is 'debug' if args=="debug" then --switch debug local value = not(mod.isDebugging); mod:EnableDebugging(value); mod:Show(value); --this module has handle the command handleIt = true; end return handleIt; end function mod.dump(...) _G.DevTools_Dump(...); end
artistic-2.0
CodeAnxiety/premake-core
src/_premake_main.lua
4
7929
-- -- _premake_main.lua -- Script-side entry point for the main program logic. -- Copyright (c) 2002-2015 Jason Perkins and the Premake project -- local shorthelp = "Type 'premake5 --help' for help" local versionhelp = "premake5 (Premake Build Script Generator) %s" local startTime = os.clock() -- set a global. _PREMAKE_STARTTIME = startTime -- Load the collection of core scripts, required for everything else to work local modules = dofile("_modules.lua") local manifest = dofile("_manifest.lua") for i = 1, #manifest do dofile(manifest[i]) end -- Create namespaces for myself local p = premake p.main = {} local m = p.main -- Keep a table of modules that have been preloaded, and their associated -- "should load" test functions. m._preloaded = {} --- -- Add a new module loader that knows how to use the Premake paths like -- PREMAKE_PATH and the --scripts option, and follows the module/module.lua -- naming convention. --- function m.installModuleLoader() table.insert(package.loaders, 2, m.moduleLoader) end function m.moduleLoader(name) local dir = path.getdirectory(name) local base = path.getname(name) if dir ~= "." then dir = dir .. "/" .. base else dir = base end local full = dir .. "/" .. base .. ".lua" -- list of paths where to look for the module local paths = { "modules/" .. full, full, name .. ".lua" } -- try to locate the module for _, p in ipairs(paths) do local file = os.locate(p) if file then local chunk, err = loadfile(file) if chunk then return chunk end if err then return "\n\tload error " .. err end end end -- didn't find the module in supported paths, try the embedded scripts for _, p in ipairs(paths) do local chunk, err = loadfile("$/" .. p) if chunk then return chunk end end end --- -- Prepare the script environment; anything that should be done -- before the system script gets a chance to run. --- function m.prepareEnvironment() math.randomseed(os.time()) _PREMAKE_DIR = path.getdirectory(_PREMAKE_COMMAND) premake.path = premake.path .. ";" .. _PREMAKE_DIR .. ";" .. _MAIN_SCRIPT_DIR end --- -- Load the required core modules that are shipped as part of Premake and -- expected to be present at startup. If a _preload.lua script is present, -- that script is run and the return value (a "should load" test) is cached -- to be called after baking is complete. Otherwise the module's main script -- is run immediately. --- function m.preloadModules() for i = 1, #modules do local name = modules[i] local preloader = name .. "/_preload.lua" preloader = os.locate("modules/" .. preloader) or os.locate(preloader) if preloader then m._preloaded[name] = include(preloader) if not m._preloaded[name] then p.warn("module '%s' should return function from _preload.lua", name) end else require(name) end end end --- -- Look for and run the system-wide configuration script; make sure any -- configuration scoping gets cleared before continuing. --- function m.runSystemScript() dofileopt(_OPTIONS["systemscript"] or { "premake5-system.lua", "premake-system.lua" }) filter {} end --- -- Look for a user project script, and set up the related global -- variables if I can find one. --- function m.locateUserScript() local defaults = { "premake5.lua", "premake4.lua" } for i = 1, #defaults do if os.isfile(defaults[i]) then _MAIN_SCRIPT = defaults[i] break end end if not _MAIN_SCRIPT then _MAIN_SCRIPT = defaults[1] end if _OPTIONS.file then _MAIN_SCRIPT = _OPTIONS.file end _MAIN_SCRIPT = path.getabsolute(_MAIN_SCRIPT) _MAIN_SCRIPT_DIR = path.getdirectory(_MAIN_SCRIPT) end --- -- Set the action to be performed from the command line arguments. --- function m.prepareAction() -- The "next-gen" actions have now replaced their deprecated counterparts. -- Provide a warning for a little while before I remove them entirely. if _ACTION and _ACTION:endswith("ng") then premake.warnOnce(_ACTION, "'%s' has been deprecated; use '%s' instead", _ACTION, _ACTION:sub(1, -3)) end premake.action.set(_ACTION) -- Allow the action to initialize stuff. local action = premake.action.current() if action then premake.action.initialize(action.trigger) end end --- -- If there is a project script available, run it to get the -- project information, available options and actions, etc. --- function m.runUserScript() if os.isfile(_MAIN_SCRIPT) then dofile(_MAIN_SCRIPT) end end --- -- Run the interactive prompt, if requested. --- function m.checkInteractive() if _OPTIONS.interactive then debug.prompt() end end --- -- Validate and process the command line options and arguments. --- function m.processCommandLine() -- Process special options if (_OPTIONS["version"]) then printf(versionhelp, _PREMAKE_VERSION) os.exit(0) end if (_OPTIONS["help"]) then premake.showhelp() os.exit(1) end -- Validate the command-line arguments. This has to happen after the -- script has run to allow for project-specific options ok, err = premake.option.validate(_OPTIONS) if not ok then print("Error: " .. err) os.exit(1) end -- If no further action is possible, show a short help message if not _OPTIONS.interactive then if not _ACTION then print(shorthelp) os.exit(1) end local action = premake.action.current() if not action then print("Error: no such action '" .. _ACTION .. "'") os.exit(1) end if p.action.isConfigurable() and not os.isfile(_MAIN_SCRIPT) then print(string.format("No Premake script (%s) found!", path.getname(_MAIN_SCRIPT))) os.exit(1) end end end --- -- Override point, for logic that should run before baking. --- function m.preBake() if p.action.isConfigurable() then print("Building configurations...") end end --- -- "Bake" the project information, preparing it for use by the action. --- function m.bake() if p.action.isConfigurable() then premake.oven.bake() end end --- -- Override point, for logic that should run after baking but before -- the configurations are validated. --- function m.postBake() local function shouldLoad(func) for wks in p.global.eachWorkspace() do for prj in p.workspace.eachproject(wks) do for cfg in p.project.eachconfig(prj) do if func(cfg) then return true end end end end end -- any modules need to load to support this project? for module, func in pairs(m._preloaded) do if not package.loaded[module] and shouldLoad(func) then require(module) end end end --- -- Sanity check the current project setup. --- function m.validate() if p.action.isConfigurable() then p.container.validate(p.api.rootContainer()) end end --- -- Override point, for logic that should run after validation and -- before the action takes control. --- function m.preAction() local action = premake.action.current() printf("Running action '%s'...", action.trigger) end --- -- Hand over control to the action. --- function m.callAction() local action = premake.action.current() premake.action.call(action.trigger) end --- -- Processing is complete. --- function m.postAction() if p.action.isConfigurable() then local duration = math.floor((os.clock() - startTime) * 1000); printf("Done (%dms).", duration) end end -- -- Script-side program entry point. -- m.elements = { m.installModuleLoader, m.locateUserScript, m.prepareEnvironment, m.preloadModules, m.runSystemScript, m.prepareAction, m.runUserScript, m.checkInteractive, m.processCommandLine, m.preBake, m.bake, m.postBake, m.validate, m.preAction, m.callAction, m.postAction, } function _premake_main() p.callArray(m.elements) return 0 end
bsd-3-clause
imLinder/dotfiles
.config/hammerspoon/Spoons/ControlEscape.spoon/init.lua
3
3040
--- === ControlEscape === --- --- Make the `control` key more useful: If the `control` key is tapped, treat it --- as the `escape` key. If the `control` key is held down and used in --- combination with another key, then provide the normal `control` key --- behavior. local obj={} obj.__index = obj -- Metadata obj.name = 'ControlEscape' obj.version = '0.1' obj.author = 'Jason Rudolph <jason@jasonrudolph.com>' obj.homepage = 'https://github.com/jasonrudolph/ControlEscape.spoon' obj.license = 'MIT - https://opensource.org/licenses/MIT' function obj:init() self.sendEscape = false self.lastModifiers = {} -- If `control` is held for this long, don't send `escape` local CANCEL_DELAY_SECONDS = 0.150 self.controlKeyTimer = hs.timer.delayed.new(CANCEL_DELAY_SECONDS, function() self.sendEscape = false end) -- Create an eventtap to run each time the modifier keys change (i.e., each -- time a key like control, shift, option, or command is pressed or released) self.controlTap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event) local newModifiers = event:getFlags() -- If this change to the modifier keys does not invole a *change* to the -- up/down state of the `control` key (i.e., it was up before and it's -- still up, or it was down before and it's still down), then don't take -- any action. if self.lastModifiers['ctrl'] == newModifiers['ctrl'] then return false end -- If the `control` key has changed to the down state, then start the -- timer. If the `control` key changes to the up state before the timer -- expires, then send `escape`. if not self.lastModifiers['ctrl'] then self.lastModifiers = newModifiers self.sendEscape = true self.controlKeyTimer:start() else if self.sendEscape then hs.eventtap.keyStroke({}, 'escape', 0) end self.lastModifiers = newModifiers self.controlKeyTimer:stop() end return false end ) -- Create an eventtap to run each time a normal key (i.e., a non-modifier key) -- enters the down state. We only want to send `escape` if `control` is -- pressed and released in isolation. If `control` is pressed in combination -- with any other key, we don't want to send `escape`. self.keyDownEventTap = hs.eventtap.new({hs.eventtap.event.types.keyDown}, function(event) self.sendEscape = false return false end ) end --- ControlEscape:start() --- Method --- Start sending `escape` when `control` is pressed and released in isolation function obj:start() self.controlTap:start() self.keyDownEventTap:start() end --- ControlEscape:stop() --- Method --- Stop sending `escape` when `control` is pressed and released in isolation function obj:stop() -- Stop monitoring keystrokes self.controlTap:stop() self.keyDownEventTap:stop() -- Reset state self.controlKeyTimer:stop() self.sendEscape = false self.lastModifiers = {} end return obj
mit
DustinMorado/tomoauto
src/lib/tomoauto/settings/MOTIONCORR.lua
1
4702
--[[ Copyright (c) 2015 Dustin Reed Morado Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]] --- Global default option value settings for MOTIONCORR. -- This module contains all of the default option values for MOTIONCORR. Every -- effort has been made to include every option. -- -- @module MOTIONCORR -- @author Dustin Reed Morado -- @license MIT -- @release 0.2.30 local config = require('tomoauto.config') local setmetatable = setmetatable _ENV = nil local MOTIONCORR = {} MOTIONCORR = { Index = 'MOTIONCORR', Name = 'TOMOAUTO{basename}_MOTIONCORR.com', Log = 'TOMOAUTO{basename}_MOTIONCORR.log', Command = '#!/bin/bash\ndosefgpu_driftcorr \\', 'InputStack', InputStack = { use = true, value = 'TOMOAUTO{path} \\' }, 'CropOffsetX', CropOffsetX = { use = false, value = '-crx 0 \\' }, 'CropOffsetY', CropOffsetY = { use = false, value = '-cry 0 \\' }, 'CropDimensionX', CropDimensionX = { use = false, value = '-cdx 0 \\' }, 'CropDimensionY', CropDimensionY = { use = false, value = '-cdy 0 \\' }, 'Binning', Binning = { use = false, value = '-bin 1 \\' }, 'AlignmentFirstFrame', AlignmentFirstFrame = { use = false, value = '-nst 0 \\' }, 'AlignmentLastFrame', AlignmentLastFrame = { use = false, value = '-ned 0 \\' }, 'SumFirstFrame', SumFirstFrame = { use = false, value = '-nss 0 \\' }, 'SumLastFrame', SumLastFrame = { use = false, value = '-nes 0 \\' }, 'GPUDeviceID', GPUDeviceID = { use = false, value = '-gpu 0 \\' }, 'BFactor', BFactor = { use = true, value = '-bft 300 \\' }, 'PeakBox', PeakBox = { use = false, value = '-pbx 96 \\' }, 'FrameOffset', FrameOffset = { use = true, value = '-fod 1 \\' }, 'NoisePeakRadius', NoisePeakRadius = { use = false, value = '-nps 0 \\' }, 'ErrorThreshold', ErrorThreshold = { use = false, value = '-kit 1.0 \\' }, 'GainReferenceFile', GainReferenceFile = { use = false, value = '-fgr FileName.mrc \\' }, 'DarkReferenceFile', DarkReferenceFile = { use = false, value = '-fdr FileName.mrc \\' }, 'SaveUncorrectedSum', SaveUncorrectedSum = { use = false, value = '-srs 0 \\' }, 'SaveUncorrectedStack', SaveUncorrectedStack = { use = false, value = '-ssr 0 \\' }, 'SaveCorrectedStack', SaveCorrectedStack = { use = false, value = '-ssc 0 \\' }, 'SaveCorrelationMap', SaveCorrelationMap = { use = false, value = '-scc 0 \\' }, 'SaveLog', SaveLog = { use = false, value = '-slg 1 \\' }, 'AlignToMiddleFrame', AlignToMiddleFrame = { use = false, value = '-atm 1 \\' }, 'SaveQuickResults', SaveQuickResults = { use = true, value = '-dsp 0 \\' }, 'UncorrectedSumOutput', UncorrectedSumOutput = { use = false, value = '-frs FileName.mrc \\' }, 'UncorrectedStackOutput', UncorrectedStackOutput = { use = false, value = '-frt FileName.mrc \\' }, 'CorrectedSumOutput', CorrectedSumOutput = { use = true, value = '-fcs TOMOAUTO{basename}_driftcorr.mrc \\' }, 'CorrectedStackOutput', CorrectedStackOutput = { use = false, value = '-fct FileName.mrc \\' }, 'CorrelationMapOutput', CorrelationMapOutput = { use = false, value = '-fcm FileName.mrc \\' }, 'LogFileOutput', LogFileOutput = { use = true, value = '-flg TOMOAUTO{basename}_driftcorr.log \\' }, } setmetatable(MOTIONCORR, { __index = config.shell }) return MOTIONCORR -- vim: set ft=lua tw=80 ts=8 sts=2 sw=2 noet :
mit
cecile/Cecile_QuickLaunch
src/Cecile_QuickLaunch/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
22
7162
--[[----------------------------------------------------------------------------- EditBox Widget -------------------------------------------------------------------------------]] local Type, Version = "EditBox", 28 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end -- Lua APIs local tostring, pairs = tostring, pairs -- WoW APIs local PlaySound = PlaySound local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo local CreateFrame, UIParent = CreateFrame, UIParent local _G = _G -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded -- List them here for Mikk's FindGlobals script -- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY --[[----------------------------------------------------------------------------- Support functions -------------------------------------------------------------------------------]] if not AceGUIEditBoxInsertLink then -- upgradeable hook hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end) end function _G.AceGUIEditBoxInsertLink(text) for i = 1, AceGUI:GetWidgetCount(Type) do local editbox = _G["AceGUI-3.0EditBox"..i] if editbox and editbox:IsVisible() and editbox:HasFocus() then editbox:Insert(text) return true end end end local function ShowButton(self) if not self.disablebutton then self.button:Show() self.editbox:SetTextInsets(0, 20, 3, 3) end end local function HideButton(self) self.button:Hide() self.editbox:SetTextInsets(0, 0, 3, 3) end --[[----------------------------------------------------------------------------- Scripts -------------------------------------------------------------------------------]] local function Control_OnEnter(frame) frame.obj:Fire("OnEnter") end local function Control_OnLeave(frame) frame.obj:Fire("OnLeave") end local function Frame_OnShowFocus(frame) frame.obj.editbox:SetFocus() frame:SetScript("OnShow", nil) end local function EditBox_OnEscapePressed(frame) AceGUI:ClearFocus() end local function EditBox_OnEnterPressed(frame) local self = frame.obj local value = frame:GetText() local cancel = self:Fire("OnEnterPressed", value) if not cancel then PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON HideButton(self) end end local function EditBox_OnReceiveDrag(frame) local self = frame.obj local type, id, info = GetCursorInfo() local name if type == "item" then name = info elseif type == "spell" then name = GetSpellInfo(id, info) elseif type == "macro" then name = GetMacroInfo(id) end if name then self:SetText(name) self:Fire("OnEnterPressed", name) ClearCursor() HideButton(self) AceGUI:ClearFocus() end end local function EditBox_OnTextChanged(frame) local self = frame.obj local value = frame:GetText() if tostring(value) ~= tostring(self.lasttext) then self:Fire("OnTextChanged", value) self.lasttext = value ShowButton(self) end end local function EditBox_OnFocusGained(frame) AceGUI:SetFocus(frame.obj) end local function Button_OnClick(frame) local editbox = frame.obj.editbox editbox:ClearFocus() EditBox_OnEnterPressed(editbox) end --[[----------------------------------------------------------------------------- Methods -------------------------------------------------------------------------------]] local methods = { ["OnAcquire"] = function(self) -- height is controlled by SetLabel self:SetWidth(200) self:SetDisabled(false) self:SetLabel() self:SetText() self:DisableButton(false) self:SetMaxLetters(0) end, ["OnRelease"] = function(self) self:ClearFocus() end, ["SetDisabled"] = function(self, disabled) self.disabled = disabled if disabled then self.editbox:EnableMouse(false) self.editbox:ClearFocus() self.editbox:SetTextColor(0.5,0.5,0.5) self.label:SetTextColor(0.5,0.5,0.5) else self.editbox:EnableMouse(true) self.editbox:SetTextColor(1,1,1) self.label:SetTextColor(1,.82,0) end end, ["SetText"] = function(self, text) self.lasttext = text or "" self.editbox:SetText(text or "") self.editbox:SetCursorPosition(0) HideButton(self) end, ["GetText"] = function(self, text) return self.editbox:GetText() end, ["SetLabel"] = function(self, text) if text and text ~= "" then self.label:SetText(text) self.label:Show() self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18) self:SetHeight(44) self.alignoffset = 30 else self.label:SetText("") self.label:Hide() self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0) self:SetHeight(26) self.alignoffset = 12 end end, ["DisableButton"] = function(self, disabled) self.disablebutton = disabled if disabled then HideButton(self) end end, ["SetMaxLetters"] = function (self, num) self.editbox:SetMaxLetters(num or 0) end, ["ClearFocus"] = function(self) self.editbox:ClearFocus() self.frame:SetScript("OnShow", nil) end, ["SetFocus"] = function(self) self.editbox:SetFocus() if not self.frame:IsShown() then self.frame:SetScript("OnShow", Frame_OnShowFocus) end end, ["HighlightText"] = function(self, from, to) self.editbox:HighlightText(from, to) end } --[[----------------------------------------------------------------------------- Constructor -------------------------------------------------------------------------------]] local function Constructor() local num = AceGUI:GetNextWidgetNum(Type) local frame = CreateFrame("Frame", nil, UIParent) frame:Hide() local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate") editbox:SetAutoFocus(false) editbox:SetFontObject(ChatFontNormal) editbox:SetScript("OnEnter", Control_OnEnter) editbox:SetScript("OnLeave", Control_OnLeave) editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed) editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed) editbox:SetScript("OnTextChanged", EditBox_OnTextChanged) editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained) editbox:SetTextInsets(0, 0, 3, 3) editbox:SetMaxLetters(256) editbox:SetPoint("BOTTOMLEFT", 6, 0) editbox:SetPoint("BOTTOMRIGHT") editbox:SetHeight(19) local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") label:SetPoint("TOPLEFT", 0, -2) label:SetPoint("TOPRIGHT", 0, -2) label:SetJustifyH("LEFT") label:SetHeight(18) local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate") button:SetWidth(40) button:SetHeight(20) button:SetPoint("RIGHT", -2, 0) button:SetText(OKAY) button:SetScript("OnClick", Button_OnClick) button:Hide() local widget = { alignoffset = 30, editbox = editbox, label = label, button = button, frame = frame, type = Type } for method, func in pairs(methods) do widget[method] = func end editbox.obj, button.obj = widget, widget return AceGUI:RegisterAsWidget(widget) end AceGUI:RegisterWidgetType(Type, Constructor, Version)
artistic-2.0
thomas-schultz/sdn-cert
feature-tests/config/action_group_select.lua
1
1275
--[[ Feature test for group type SELECT ]] require "feature_config" local Feature = FeatureConfig.new() Feature.require = "OpenFLow11" Feature.state = "optional" Feature.loadGen = "moongen" Feature.files = "feature_test.lua" Feature.lgArgs = "$file=1 $name $link=1 $link=2" Feature.ofArgs = "$link=2" Feature.pkt = Feature.getDefaultPkt() Feature.settings = { new_SRC_IP4 = "10.0.2.1", new_DST_IP4 = "10.0.2.2", } local conf = Feature.settings Feature.flowEntries = function(flowData, outPort) table.insert(flowData.groups, string.format("group_id=1, type=select, bucket=mod_nw_src=%s,output:%s, bucket=mod_nw_dst=%s,output:%s", conf.new_SRC_IP4, outPort, conf.new_DST_IP4, outPort)) table.insert(flowData.flows, "actions=group:1") end Feature.pktClassifier = { function(pkt) return (pkt.src_ip == conf.new_SRC_IP4 and pkt.dst_ip ~= conf.new_DST_IP4) end, function(pkt) return (pkt.src_ip ~= conf.new_SRC_IP4 and pkt.dst_ip == conf.new_DST_IP4) end, } Feature.evalCounters = function(ctrs, batch, threshold) return (Feature.eval(ctrs[1],batch,threshold) and not Feature.eval(ctrs[2],batch,threshold)) or (not Feature.eval(ctrs[1],batch,threshold) and Feature.eval(ctrs[2],batch,threshold)) end return Feature
gpl-2.0
dhotson/prosody-modules
mod_checkcerts/mod_checkcerts.lua
29
2809
local ssl = require"ssl"; local datetime_parse = require"util.datetime".parse; local load_cert = ssl.loadcertificate; local st = require"util.stanza" -- These are in days. local nag_time = module:get_option_number("checkcerts_notify", 7) * 86400; if not load_cert then module:log("error", "This version of LuaSec (%s) does not support certificate checking", ssl._VERSION); return end local pat = "^([JFMAONSD][ceupao][glptbvyncr]) ?(%d%d?) (%d%d):(%d%d):(%d%d) (%d%d%d%d) GMT$"; local months = {Jan=1,Feb=2,Mar=3,Apr=4,May=5,Jun=6,Jul=7,Aug=8,Sep=9,Oct=10,Nov=11,Dec=12}; local function parse_x509_datetime(s) local month, day, hour, min, sec, year = s:match(pat); month = months[month]; return datetime_parse(("%04d-%02d-%02dT%02d:%02d:%02dZ"):format(year, month, day, hour, min, sec)); end local timeunits = {"minute",60,"hour",3600,"day",86400,"week",604800,"month",2629746,"year",31556952,}; local function humantime(timediff) local ret = {}; for i=#timeunits,2,-2 do if timeunits[i] < timediff then local n = math.floor(timediff / timeunits[i]); if n > 0 and #ret < 2 then ret[#ret+1] = ("%d %s%s"):format(n, timeunits[i-1], n ~= 1 and "s" or ""); timediff = timediff - n*timeunits[i]; end end end return table.concat(ret, " and ") end local function check_certs_validity() local now = os.time(); -- First, let's find out what certificate this host uses. local ssl_config = config.rawget(module.host, "ssl"); if not ssl_config then local base_host = module.host:match("%.(.*)"); ssl_config = config.get(base_host, "ssl"); end if ssl_config and ssl_config.certificate then local certfile = ssl_config.certificate; local fh = io.open(certfile); -- Load the file. cert = fh and fh:read"*a"; fh = fh and fh:close(); local cert = cert and load_cert(cert); -- And parse if not cert then module:log("warn", "No certificate configured for this host, please fix this and reload this module to check expiry"); return end local expires_at = parse_x509_datetime(cert:notafter()); local expires_in = os.difftime(expires_at, now); local fmt = "Certificate %s expires in %s" local nag_admin = expires_in < nag_time; local log_warn = expires_in < nag_time * 2; local timediff = expires_in; if expires_in < 0 then fmt = "Certificate %s expired %s ago"; timediff = -timediff; end timediff = humantime(timediff); module:log(log_warn and "warn" or "info", fmt, certfile, timediff); if nag_admin then local body = fmt:format("for host ".. module.host, timediff); for _,admin in ipairs(module:get_option_array("admins", {})) do module:send(st.message({ from = module.host, to = admin, type = "chat" }, body)); end end return math.max(86400, expires_in / 3); end end module:add_timer(1, check_certs_validity);
mit
KayMD/Illarion-Content
monster/race_11_skeleton/default.lua
3
1059
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- About the Weakened Lich. -- Appears from a pile of bones dropped by a normal lich. That lich hasnt droped anything except this bones. -- You get the loot for the normal lich if you kill that weakened lich. Therefore, this loot is more expensive than -- a monster of this category would normally drop. local skeletons = require("monster.race_11_skeleton.base") return skeletons.generateCallbacks()
agpl-3.0
Tarfand-pro/BDReborn
bot/utils.lua
3
22540
--Begin Utils.lua By #BeyondTeam :) local clock = os.clock function sleep(time) -- seconds local t0 = clock() while clock() - t0 <= time do end end function var_cb(msg, data) -------------Get Var------------ bot = {} msg.to = {} msg.from = {} msg.media = {} msg.id = msg.id_ msg.to.type = gp_type(data.chat_id_) if data.content_.caption_ then msg.media.caption = data.content_.caption_ end if data.reply_to_message_id_ ~= 0 then msg.reply_id = data.reply_to_message_id_ else msg.reply_id = false end function get_gp(arg, data) if gp_type(msg.chat_id_) == "channel" or gp_type(msg.chat_id_) == "chat" then msg.to.id = msg.chat_id_ msg.to.title = data.title_ else msg.to.id = msg.chat_id_ msg.to.title = false end end tdcli_function ({ ID = "GetChat", chat_id_ = data.chat_id_ }, get_gp, nil) function botifo_cb(arg, data) bot.id = data.id_ our_id = data.id_ if data.username_ then bot.username = data.username_ else bot.username = false end if data.first_name_ then bot.first_name = data.first_name_ end if data.last_name_ then bot.last_name = data.last_name_ else bot.last_name = false end if data.first_name_ and data.last_name_ then bot.print_name = data.first_name_..' '..data.last_name_ else bot.print_name = data.first_name_ end if data.phone_number_ then bot.phone = data.phone_number_ else bot.phone = false end end tdcli_function({ ID = 'GetMe'}, botifo_cb, {chat_id=msg.chat_id_}) function get_user(arg, data) msg.from.id = data.id_ if data.username_ then msg.from.username = data.username_ else msg.from.username = false end if data.first_name_ then msg.from.first_name = data.first_name_ end if data.last_name_ then msg.from.last_name = data.last_name_ else msg.from.last_name = false end if data.first_name_ and data.last_name_ then msg.from.print_name = data.first_name_..' '..data.last_name_ else msg.from.print_name = data.first_name_ end if data.phone_number_ then msg.from.phone = data.phone_number_ else msg.from.phone = false end match_plugins(msg) end tdcli_function ({ ID = "GetUser", user_id_ = data.sender_user_id_ }, get_user, nil) -------------End------------- end function set_config(msg) local function config_cb(arg, data) local hash = "gp_lang:"..msg.to.id local lang = redis:get(hash) --print(serpent.block(data)) for k,v in pairs(data.members_) do local function config_mods(arg, data) local administration = load_data(_config.moderation.data) if data.username_ then user_name = '@'..check_markdown(data.username_) else user_name = check_markdown(data.first_name_) end administration[tostring(msg.to.id)]['mods'][tostring(data.id_)] = user_name save_data(_config.moderation.data, administration) end tdcli_function ({ ID = "GetUser", user_id_ = v.user_id_ }, config_mods, {user_id=v.user_id_}) if data.members_[k].status_.ID == "ChatMemberStatusCreator" then owner_id = v.user_id_ local function config_owner(arg, data) -- print(serpent.block(data)) local administration = load_data(_config.moderation.data) if data.username_ then user_name = '@'..check_markdown(data.username_) else user_name = check_markdown(data.first_name_) end administration[tostring(msg.to.id)]['owners'][tostring(data.id_)] = user_name save_data(_config.moderation.data, administration) end tdcli_function ({ ID = "GetUser", user_id_ = owner_id }, config_owner, {user_id=owner_id}) end end if not lang then return tdcli.sendMessage(msg.to.id, msg.id, 0, "_All group admins has been promoted and group creator is now group owner_", 0, "md") else return tdcli.sendMessage(msg.to.id, msg.id, 0, "_تمام ادمین های گروه به مقام مدیر منتصب شدند و سازنده گروه به مقام مالک گروه منتصب شد_", 0, "md") end end tdcli.getChannelMembers(msg.to.id, 0, 'Administrators', 200, config_cb, {chat_id=msg.to.id}) end function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- checking -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end -- return return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- do ski msg_caption = ''..string.reverse("") -- Waiting for ski:) -- and content-type for extension function download_to_file(url, file_name) -- print to server -- print("url to download: "..url) -- uncomment if needed local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "data/"..file_name -- print("Saved to: "..file_path) -- uncomment if needed file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) -- print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") -- uncomment if needed return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end function pairsByKeys (t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end function run_bash(str) local cmd = io.popen(str) local result = cmd:read('*all') return result end function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end function gp_type(chat_id) local gp_type = "pv" local id = tostring(chat_id) if id:match("^-100") then gp_type = "channel" elseif id:match("-") then gp_type = "chat" end return gp_type end function is_reply(msg) local var = false if msg.reply_to_message_id_ ~= 0 then -- reply message id is not 0 var = true end return var end function is_supergroup(msg) chat_id = tostring(msg.chat_id_) if chat_id:match('^-100') then --supergroups and channels start with -100 if not msg.is_post_ then return true end else return false end end function is_channel(msg) chat_id = tostring(msg.chat_id_) if chat_id:match('^-100') then -- Start with -100 (like channels and supergroups) if msg.is_post_ then -- message is a channel post return true else return false end end end function is_group(msg) chat_id = tostring(msg.chat_id_) if chat_id:match('^-100') then --not start with -100 (normal groups does not have -100 in first) return false elseif chat_id:match('^-') then return true else return false end end function is_private(msg) chat_id = tostring(msg.chat_id_) if chat_id:match('^-') then --private chat does not start with - return false else return true end end function check_markdown(text) --markdown escape ( when you need to escape markdown , use it like : check_markdown('your text') str = text if str:match('_') then output = str:gsub('_',[[\_]]) elseif str:match('*') then output = str:gsub('*','\\*') elseif str:match('`') then output = str:gsub('`','\\`') else output = str end return output end function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.sender_user_id_ then var = true end end return var end function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.sender_user_id_ if data[tostring(msg.chat_id_)] then if data[tostring(msg.chat_id_)]['owners'] then if data[tostring(msg.chat_id_)]['owners'][tostring(msg.sender_user_id_)] then var = true end end end for v,user in pairs(_config.admins) do if user[1] == msg.sender_user_id_ then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.sender_user_id_ then var = true end end return var end function is_admin(msg) local var = false local user = msg.sender_user_id_ for v,user in pairs(_config.admins) do if user[1] == msg.sender_user_id_ then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.sender_user_id_ then var = true end end return var end --Check if user is the mod of that group or not function is_mod(msg) local var = false local data = load_data(_config.moderation.data) local usert = msg.sender_user_id_ if data[tostring(msg.chat_id_)] then if data[tostring(msg.chat_id_)]['mods'] then if data[tostring(msg.chat_id_)]['mods'][tostring(msg.sender_user_id_)] then var = true end end end if data[tostring(msg.chat_id_)] then if data[tostring(msg.chat_id_)]['owners'] then if data[tostring(msg.chat_id_)]['owners'][tostring(msg.sender_user_id_)] then var = true end end end for v,user in pairs(_config.admins) do if user[1] == msg.sender_user_id_ then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.sender_user_id_ then var = true end end return var end function is_sudo1(user_id) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end function is_owner1(chat_id, user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id if data[tostring(chat_id)] then if data[tostring(chat_id)]['owners'] then if data[tostring(chat_id)]['owners'][tostring(user)] then var = true end end end for v,user in pairs(_config.admins) do if user[1] == user_id then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end function is_admin1(user_id) local var = false local user = user_id for v,user in pairs(_config.admins) do if user[1] == user_id then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_mod1(chat_id, user_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(chat_id)] then if data[tostring(chat_id)]['mods'] then if data[tostring(chat_id)]['mods'][tostring(usert)] then var = true end end end if data[tostring(chat_id)] then if data[tostring(chat_id)]['owners'] then if data[tostring(chat_id)]['owners'][tostring(usert)] then var = true end end end for v,user in pairs(_config.admins) do if user[1] == user_id then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = '*This plugin requires privileged user*' local receiver = msg.chat_id_ tdcli.sendMessage(msg.chat_id_, "", 0, result, 0, "md") return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function is_banned(user_id, chat_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(chat_id)] then if data[tostring(chat_id)]['banned'] then if data[tostring(chat_id)]['banned'][tostring(user_id)] then var = true end end end return var end function is_silent_user(user_id, chat_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(chat_id)] then if data[tostring(chat_id)]['is_silent_users'] then if data[tostring(chat_id)]['is_silent_users'][tostring(user_id)] then var = true end end end return var end function is_whitelist(user_id, chat_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(chat_id)] then if data[tostring(chat_id)]['whitelist'] then if data[tostring(chat_id)]['whitelist'][tostring(user_id)] then var = true end end end return var end function is_gbanned(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local gban_users = 'gban_users' if data[tostring(gban_users)] then if data[tostring(gban_users)][tostring(user)] then var = true end end return var end function is_filter(msg, text) local var = false local data = load_data(_config.moderation.data) if data[tostring(msg.chat_id_)]['filterlist'] then for k,v in pairs(data[tostring(msg.chat_id_)]['filterlist']) do if string.find(string.lower(text), string.lower(k)) then var = true end end end return var end function kick_user(user_id, chat_id) if not tonumber(user_id) then return false end tdcli.changeChatMemberStatus(chat_id, user_id, 'Kicked', dl_cb, nil) end function del_msg(chat_id, message_ids) local msgid = {[0] = message_ids} tdcli.deleteMessages(chat_id, msgid, dl_cb, nil) end function channel_unblock(chat_id, user_id) tdcli.changeChatMemberStatus(chat_id, user_id, 'Left', dl_cb, nil) end function channel_set_admin(chat_id, user_id) tdcli.changeChatMemberStatus(chat_id, user_id, 'Editor', dl_cb, nil) end function channel_set_mod(chat_id, user_id) tdcli.changeChatMemberStatus(chat_id, user_id, 'Moderator', dl_cb, nil) end function channel_demote(chat_id, user_id) tdcli.changeChatMemberStatus(chat_id, user_id, 'Member', dl_cb, nil) end function file_dl(file_id) tdcli.downloadFile(file_id, dl_cb, nil) end function banned_list(chat_id) local hash = "gp_lang:"..chat_id local lang = redis:get(hash) local data = load_data(_config.moderation.data) local i = 1 if not data[tostring(chat_id)] then if not lang then return '_Group is not added_' else return 'گروه به لیست گروه های مدیریتی ربات اضافه نشده است' end end -- determine if table is empty if next(data[tostring(chat_id)]['banned']) == nil then --fix way if not lang then return "_No_ *banned* _users in this group_" else return "*هیچ کاربری از این گروه محروم نشده*" end end if not lang then message = '*List of banned users :*\n' else message = '_لیست کاربران محروم شده از گروه :_\n' end for k,v in pairs(data[tostring(chat_id)]['banned']) do message = message ..i.. '- '..v..' [' ..k.. '] \n' i = i + 1 end return message end function silent_users_list(chat_id) local hash = "gp_lang:"..chat_id local lang = redis:get(hash) local data = load_data(_config.moderation.data) local i = 1 if not data[tostring(chat_id)] then if not lang then return '_Group is not added_' else return 'گروه به لیست گروه های مدیریتی ربات اضافه نشده است' end end -- determine if table is empty if next(data[tostring(chat_id)]['is_silent_users']) == nil then --fix way if not lang then return "_No_ *silent* _users in this group_" else return "*لیست کاربران سایلنت شده خالی است*" end end if not lang then message = '*List of silent users :*\n' else message = '_لیست کاربران سایلنت شده :_\n' end for k,v in pairs(data[tostring(chat_id)]['is_silent_users']) do message = message ..i.. '- '..v..' [' ..k.. '] \n' i = i + 1 end return message end function whitelist(chat_id) local hash = "gp_lang:"..chat_id local lang = redis:get(hash) local data = load_data(_config.moderation.data) local i = 1 if not data[tostring(chat_id)] then if not lang then return '_Group is not added_' else return 'گروه به لیست گروه های مدیریتی ربات اضافه نشده است' end end if not data[tostring(chat_id)]['whitelist'] then data[tostring(chat_id)]['whitelist'] = {} save_data(_config.moderation.data, data) end -- determine if table is empty if next(data[tostring(chat_id)]['whitelist']) == nil then --fix way if not lang then return "_No_ *users* _in white list_" else return "*هیچ کاربری در لیست سفید وجود ندارد*" end end if not lang then message = '*Users of white list :*\n' else message = '_کاربران لیست سفید :_\n' end for k,v in pairs(data[tostring(chat_id)]['whitelist']) do message = message ..i.. '- '..v..' [' ..k.. '] \n' i = i + 1 end return message end function gbanned_list(msg) local hash = "gp_lang:"..msg.chat_id_ local lang = redis:get(hash) local data = load_data(_config.moderation.data) local i = 1 if not data['gban_users'] then data['gban_users'] = {} save_data(_config.moderation.data, data) end if next(data['gban_users']) == nil then --fix way if not lang then return "_No_ *globally banned* _users available_" else return "*هیچ کاربری از گروه های ربات محروم نشده*" end end if not lang then message = '*List of globally banned users :*\n' else message = '_لیست کاربران محروم شده از گروه های ربات :_\n' end for k,v in pairs(data['gban_users']) do message = message ..i.. '- '..v..' [' ..k.. '] \n' i = i + 1 end return message end function filter_list(msg) local hash = "gp_lang:"..msg.chat_id_ local lang = redis:get(hash) local data = load_data(_config.moderation.data) if not data[tostring(msg.chat_id_)]['filterlist'] then data[tostring(msg.chat_id_)]['filterlist'] = {} save_data(_config.moderation.data, data) end if not data[tostring(msg.chat_id_)] then if not lang then return '_Group is not added_' else return 'گروه به لیست گروه های مدیریتی ربات اضافه نشده است' end end -- determine if table is empty if next(data[tostring(msg.chat_id_)]['filterlist']) == nil then --fix way if not lang then return "*Filtered words list* _is empty_" else return "_لیست کلمات فیلتر شده خالی است_" end end if not data[tostring(msg.chat_id_)]['filterlist'] then data[tostring(msg.chat_id_)]['filterlist'] = {} save_data(_config.moderation.data, data) end if not lang then filterlist = '*List of filtered words :*\n' else filterlist = '_لیست کلمات فیلتر شده :_\n' end local i = 1 for k,v in pairs(data[tostring(msg.chat_id_)]['filterlist']) do filterlist = filterlist..'*'..i..'* - _'..check_markdown(k)..'_\n' i = i + 1 end return filterlist end
gpl-3.0
gajop/Zero-K
units/gunshipaa.lua
2
6262
unitDef = { unitname = [[gunshipaa]], name = [[Trident]], description = [[Anti-Air Gunship]], acceleration = 0.18, airStrafe = 0, amphibious = true, bankingAllowed = false, brakeRate = 0.5, buildCostEnergy = 270, buildCostMetal = 270, builder = false, buildPic = [[gunshipaa.png]], buildTime = 270, canAttack = true, canFly = true, canGuard = true, canMove = true, canPatrol = true, canSubmerge = false, category = [[GUNSHIP]], collisionVolumeOffsets = [[0 0 0]], collisionVolumeScales = [[36 36 36]], collisionVolumeTest = 1, collisionVolumeType = [[ellipsoid]], collide = true, corpse = [[DEAD]], cruiseAlt = 110, customParams = { --description_bp = [[Aeronave flutuadora agressora]], --description_fr = [[ADAV Pilleur]], description_de = [[Flugabwehr Hubschrauber]], description_pl = [[Przeciwlotniczy statek powietrzny]], helptext = [[The Trident is a slow gunship that cuts down enemy aircraft with missiles. It is much slower than other gunships, so it is much easier to kill the Trident with ground units than with planes.]], --helptext_bp = [[A aeronave flutuante agressora leve de Logos. Seus mísseis s?o precisos e pode atingir o ar, tornando-a útil contra alvos pequenos e outras aeronaves agressoras.]], --helptext_fr = [[des missiles pr?cis et une vitesse de vol appr?ciable, le Rapier saura vous d?fendre contre d'autres pilleurs ou mener des assauts rapides.]], --helptext_de = [[Der Rapier ist ein leichter Raiderhubschrauber. Seine Raketen sind akkurat und treffen auch Lufteinheiten. Des Weiteren erweist er sich gegen kleine Ziele und als Gegenwehr gegen andere Raider als sehr nützlich.]], helptext_pl = [[Trident to wolny statek powietrzny, ktory niszczy lotnictwo silnymi rakietami. Jego szybkosc i niski pulap sprawiaja jednak, ze mozna go latwo zniszczyc jednostkami naziemnymi.]], modelradius = [[18]], midposoffset = [[0 15 0]], selection_velocity_heading = 1, }, explodeAs = [[GUNSHIPEX]], floater = true, footprintX = 3, footprintZ = 3, hoverAttack = true, iconType = [[gunshipaa]], idleAutoHeal = 5, idleTime = 1800, mass = 208, maxDamage = 900, maxVelocity = 3.8, minCloakDistance = 75, noAutoFire = false, noChaseCategory = [[TERRAFORM LAND SINK TURRET SHIP SWIM FLOAT SUB HOVER]], objectName = [[trifighter.s3o]], script = [[gunshipaa.lua]], seismicSignature = 0, selfDestructAs = [[GUNSHIPEX]], sfxtypes = { explosiongenerators = { [[custom:rapiermuzzle]], }, }, side = [[CORE]], sightDistance = 660, smoothAnim = true, turnRate = 0, workerTime = 0, weapons = { { def = [[AA_MISSILE]], --badTargetCategory = [[GUNSHIP]], onlyTargetCategory = [[GUNSHIP FIXEDWING]], }, }, weaponDefs = { AA_MISSILE = { name = [[Homing Missiles]], areaOfEffect = 48, avoidFeature = false, canattackground = false, cegTag = [[missiletrailblue]], collideFriendly = false, craterBoost = 1, craterMult = 2, cylinderTargeting = 1, customParams = { isaa = [[1]], script_reload = [[10]], script_burst = [[3]], light_camera_height = 2500, light_radius = 200, light_color = [[0.5 0.6 0.6]], }, damage = { default = 20.01, planes = 200.1, subs = 3.5, }, explosionGenerator = [[custom:FLASH2]], fireStarter = 70, fixedlauncher = true, flightTime = 3, impulseBoost = 0, impulseFactor = 0.4, interceptedByShieldType = 2, model = [[wep_m_fury.s3o]], noSelfDamage = true, range = 750, reloadtime = 1.2, smokeTrail = true, soundHit = [[weapon/missile/rocket_hit]], soundStart = [[weapon/missile/missile_fire7]], startVelocity = 650, texture2 = [[AAsmoketrail]], texture3 = [[null]], tolerance = 32767, tracks = true, turnRate = 90000, turret = false, weaponAcceleration = 550, weaponTimer = 0.2, weaponType = [[StarburstLauncher]], weaponVelocity = 700, }, }, featureDefs = { DEAD = { description = [[Wreckage - Trident]], blocking = true, category = [[corpses]], damage = 900, energy = 0, featureDead = [[HEAP]], footprintX = 2, footprintZ = 2, height = [[40]], hitdensity = [[100]], metal = 108, object = [[trifighter_dead.s3o]], reclaimable = true, reclaimTime = 108, }, HEAP = { description = [[Debris - Trident]], blocking = false, category = [[heaps]], damage = 900, energy = 0, footprintX = 2, footprintZ = 2, height = [[4]], hitdensity = [[100]], metal = 54, object = [[debris3x3c.s3o]], reclaimable = true, reclaimTime = 54, }, }, } return lowerkeys({ gunshipaa = unitDef })
gpl-2.0
danteinforno/wesnoth
data/ai/micro_ais/cas/ca_hunter.lua
26
8246
local H = wesnoth.require "lua/helper.lua" local W = H.set_wml_action_metatable {} local AH = wesnoth.require "ai/lua/ai_helper.lua" local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua" local function hunter_attack_weakest_adj_enemy(ai, hunter) -- Attack the enemy with the fewest hitpoints adjacent to 'hunter', if there is one -- Returns status of the attack: -- 'attacked': if a unit was attacked -- 'killed': if a unit was killed -- 'no_attack': if no unit was attacked if (hunter.attacks_left == 0) then return 'no_attack' end local min_hp, target = 9e99 for xa,ya in H.adjacent_tiles(hunter.x, hunter.y) do local enemy = wesnoth.get_unit(xa, ya) if enemy and wesnoth.is_enemy(enemy.side, wesnoth.current.side) then if (enemy.hitpoints < min_hp) then min_hp, target = enemy.hitpoints, enemy end end end if target then AH.checked_attack(ai, hunter, target) if target and target.valid then return 'attacked' else return 'killed' end end return 'no_attack' end local function get_hunter(cfg) local filter = cfg.filter or { id = cfg.id } local hunter = AH.get_units_with_moves { side = wesnoth.current.side, { "and", filter } }[1] return hunter end local ca_hunter = {} function ca_hunter:evaluation(ai, cfg) if get_hunter(cfg) then return cfg.ca_score end return 0 end function ca_hunter:execution(ai, cfg) -- Hunter does a random wander in area given by @cfg.hunting_ground until it finds -- and kills an enemy unit, then retreats to position given by @cfg.home_x/y -- for @cfg.rest_turns turns, or until fully healed local hunter = get_hunter(cfg) local hunter_vars = MAIUV.get_mai_unit_variables(hunter, cfg.ai_id) -- If hunting_status is not set for the hunter -> default behavior -> random wander if (not hunter_vars.hunting_status) then -- Hunter gets a new goal if none exist or on any move with 10% random chance local rand = math.random(10) if (not hunter_vars.goal_x) or (rand == 1) then -- 'locs' includes border hexes, but that does not matter here locs = AH.get_passable_locations((cfg.filter_location or {}), hunter) local rand = math.random(#locs) hunter_vars.goal_x, hunter_vars.goal_y = locs[rand][1], locs[rand][2] MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) end local reach_map = AH.get_reachable_unocc(hunter) -- Now find the one of these hexes that is closest to the goal local max_rating, best_hex = -9e99 reach_map:iter( function(x, y, v) -- Distance from goal is first rating local rating = - H.distance_between(x, y, hunter_vars.goal_x, hunter_vars.goal_y) -- Huge rating bonus if this is next to an enemy local enemy_hp = 500 for xa,ya in H.adjacent_tiles(x, y) do local enemy = wesnoth.get_unit(xa, ya) if enemy and wesnoth.is_enemy(enemy.side, wesnoth.current.side) then if (enemy.hitpoints < enemy_hp) then enemy_hp = enemy.hitpoints end end end rating = rating + 500 - enemy_hp -- prefer attack on weakest enemy if (rating > max_rating) then max_rating, best_hex = rating, { x, y } end end) if (best_hex[1] ~= hunter.x) or (best_hex[2] ~= hunter.y) then AH.checked_move(ai, hunter, best_hex[1], best_hex[2]) -- partial move only if (not hunter) or (not hunter.valid) then return end else -- If hunter did not move, we need to stop it (also delete the goal) AH.checked_stopunit_moves(ai, hunter) if (not hunter) or (not hunter.valid) then return end hunter_vars.goal_x, hunter_vars.goal_y = nil, nil MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) end -- If this gets the hunter to the goal, we delete the goal if (hunter.x == hunter_vars.goal_x) and (hunter.y == hunter_vars.goal_y) then hunter_vars.goal_x, hunter_vars.goal_y = nil, nil MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) end -- Finally, if the hunter ended up next to enemies, attack the weakest of those local attack_status = hunter_attack_weakest_adj_enemy(ai, hunter) -- If the enemy was killed, hunter returns home if hunter and hunter.valid and (attack_status == 'killed') then hunter_vars.goal_x, hunter_vars.goal_y = nil, nil hunter_vars.hunting_status = 'returning' MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) if cfg.show_messages then W.message { speaker = hunter.id, message = 'Now that I have eaten, I will go back home.' } end end return end -- If we got here, this means the hunter is either returning, or resting if (hunter_vars.hunting_status == 'returning') then goto_x, goto_y = wesnoth.find_vacant_tile(cfg.home_x, cfg.home_y) local next_hop = AH.next_hop(hunter, goto_x, goto_y) if next_hop then AH.movefull_stopunit(ai, hunter, next_hop) if (not hunter) or (not hunter.valid) then return end -- If there's an enemy on the 'home' hex and we got right next to it, attack that enemy if (H.distance_between(cfg.home_x, cfg.home_y, next_hop[1], next_hop[2]) == 1) then local enemy = wesnoth.get_unit(cfg.home_x, cfg.home_y) if enemy and wesnoth.is_enemy(enemy.side, hunter.side) then if cfg.show_messages then W.message { speaker = hunter.id, message = 'Get out of my home!' } end AH.checked_attack(ai, hunter, enemy) if (not hunter) or (not hunter.valid) then return end end end end -- We also attack the weakest adjacent enemy, if still possible hunter_attack_weakest_adj_enemy(ai, hunter) if (not hunter) or (not hunter.valid) then return end -- If the hunter got home, start the resting counter if (hunter.x == cfg.home_x) and (hunter.y == cfg.home_y) then hunter_vars.hunting_status = 'resting' hunter_vars.resting_until = wesnoth.current.turn + (cfg.rest_turns or 3) MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) if cfg.show_messages then W.message { speaker = hunter.id, message = 'I made it home - resting now until the end of Turn ' .. hunter_vars.resting_until .. ' or until fully healed.' } end end return end -- If we got here, the only remaining action should be resting if (hunter_vars.hunting_status == 'resting') then AH.checked_stopunit_moves(ai, hunter) if (not hunter) or (not hunter.valid) then return end -- We also attack the weakest adjacent enemy hunter_attack_weakest_adj_enemy(ai, hunter) if (not hunter) or (not hunter.valid) then return end -- If this is the last turn of resting, we remove the status and turn variable if (hunter.hitpoints >= hunter.max_hitpoints) and (hunter_vars.resting_until <= wesnoth.current.turn) then hunter_vars.hunting_status = nil hunter_vars.resting_until = nil MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) if cfg.show_messages then W.message { speaker = hunter.id, message = 'I am done resting. It is time to go hunting again next turn.' } end end return end -- In principle we should never get here, but just in case something got changed in WML: -- Reset variable, so that hunter goes hunting on next turn hunter_vars.hunting_status = nil MAIUV.set_mai_unit_variables(hunter, cfg.ai_id, hunter_vars) end return ca_hunter
gpl-2.0
nobie/sesame_fw
feeds/luci/libs/nixio/lua/nixio/util.lua
179
5824
--[[ nixio - Linux I/O library for lua Copyright 2009 Steven Barth <steven@midlink.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- local table = require "table" local nixio = require "nixio" local getmetatable, assert, pairs, type = getmetatable, assert, pairs, type local tostring = tostring module "nixio.util" local BUFFERSIZE = nixio.const.buffersize local ZIOBLKSIZE = 65536 local socket = nixio.meta_socket local tls_socket = nixio.meta_tls_socket local file = nixio.meta_file local uname = nixio.uname() local ZBUG = uname.sysname == "Linux" and uname.release:sub(1, 3) == "2.4" function consume(iter, append) local tbl = append or {} if iter then for obj in iter do tbl[#tbl+1] = obj end end return tbl end local meta = {} function meta.is_socket(self) return (getmetatable(self) == socket) end function meta.is_tls_socket(self) return (getmetatable(self) == tls_socket) end function meta.is_file(self) return (getmetatable(self) == file) end function meta.readall(self, len) local block, code, msg = self:read(len or BUFFERSIZE) if not block then return nil, code, msg, "" elseif #block == 0 then return "", nil, nil, "" end local data, total = {block}, #block while not len or len > total do block, code, msg = self:read(len and (len - total) or BUFFERSIZE) if not block then return nil, code, msg, table.concat(data) elseif #block == 0 then break end data[#data+1], total = block, total + #block end local data = #data > 1 and table.concat(data) or data[1] return data, nil, nil, data end meta.recvall = meta.readall function meta.writeall(self, data) data = tostring(data) local sent, code, msg = self:write(data) if not sent then return nil, code, msg, 0 end local total = sent while total < #data do sent, code, msg = self:write(data, total) if not sent then return nil, code, msg, total end total = total + sent end return total, nil, nil, total end meta.sendall = meta.writeall function meta.linesource(self, limit) limit = limit or BUFFERSIZE local buffer = "" local bpos = 0 return function(flush) local line, endp, _ if flush then line = buffer:sub(bpos + 1) buffer = type(flush) == "string" and flush or "" bpos = 0 return line end while not line do _, endp, line = buffer:find("(.-)\r?\n", bpos + 1) if line then bpos = endp return line elseif #buffer < limit + bpos then local newblock, code, msg = self:read(limit + bpos - #buffer) if not newblock then return nil, code, msg elseif #newblock == 0 then return nil end buffer = buffer:sub(bpos + 1) .. newblock bpos = 0 else return nil, 0 end end end end function meta.blocksource(self, bs, limit) bs = bs or BUFFERSIZE return function() local toread = bs if limit then if limit < 1 then return nil elseif limit < toread then toread = limit end end local block, code, msg = self:read(toread) if not block then return nil, code, msg elseif #block == 0 then return nil else if limit then limit = limit - #block end return block end end end function meta.sink(self, close) return function(chunk, src_err) if not chunk and not src_err and close then if self.shutdown then self:shutdown() end self:close() elseif chunk and #chunk > 0 then return self:writeall(chunk) end return true end end function meta.copy(self, fdout, size) local source = self:blocksource(nil, size) local sink = fdout:sink() local sent, chunk, code, msg = 0 repeat chunk, code, msg = source() sink(chunk, code, msg) sent = chunk and (sent + #chunk) or sent until not chunk return not code and sent or nil, code, msg, sent end function meta.copyz(self, fd, size) local sent, lsent, code, msg = 0 local splicable if not ZBUG and self:is_file() then local ftype = self:stat("type") if nixio.sendfile and fd:is_socket() and ftype == "reg" then repeat lsent, code, msg = nixio.sendfile(fd, self, size or ZIOBLKSIZE) if lsent then sent = sent + lsent size = size and (size - lsent) end until (not lsent or lsent == 0 or (size and size == 0)) if lsent or (not lsent and sent == 0 and code ~= nixio.const.ENOSYS and code ~= nixio.const.EINVAL) then return lsent and sent, code, msg, sent end elseif nixio.splice and not fd:is_tls_socket() and ftype == "fifo" then splicable = true end end if nixio.splice and fd:is_file() and not splicable then splicable = not self:is_tls_socket() and fd:stat("type") == "fifo" end if splicable then repeat lsent, code, msg = nixio.splice(self, fd, size or ZIOBLKSIZE) if lsent then sent = sent + lsent size = size and (size - lsent) end until (not lsent or lsent == 0 or (size and size == 0)) if lsent or (not lsent and sent == 0 and code ~= nixio.const.ENOSYS and code ~= nixio.const.EINVAL) then return lsent and sent, code, msg, sent end end return self:copy(fd, size) end if tls_socket then function tls_socket.close(self) return self.socket:close() end function tls_socket.getsockname(self) return self.socket:getsockname() end function tls_socket.getpeername(self) return self.socket:getpeername() end function tls_socket.getsockopt(self, ...) return self.socket:getsockopt(...) end tls_socket.getopt = tls_socket.getsockopt function tls_socket.setsockopt(self, ...) return self.socket:setsockopt(...) end tls_socket.setopt = tls_socket.setsockopt end for k, v in pairs(meta) do file[k] = v socket[k] = v if tls_socket then tls_socket[k] = v end end
gpl-2.0
pixeltailgames/gm-mediaplayer
lua/mediaplayer/players/base/cl_init.lua
1
3723
include "shared.lua" include "cl_draw.lua" include "cl_fullscreen.lua" include "net.lua" local CeilPower2 = MediaPlayerUtils.CeilPower2 function MEDIAPLAYER:NetReadUpdate() -- Allows for another media player type to extend update net messages end function MEDIAPLAYER:OnNetReadMedia( media ) -- Allows for another media player type to extend media net messages end function MEDIAPLAYER:OnQueueKeyPressed( down, held ) self._LastMediaUpdate = RealTime() end --[[--------------------------------------------------------- Networking -----------------------------------------------------------]] local function OnMediaUpdate( len ) local mpId = net.ReadString() local mpType = net.ReadString() if MediaPlayer.DEBUG then print( "Received MEDIAPLAYER.Update", mpId, mpType ) end local mp = MediaPlayer.GetById(mpId) if not mp then mp = MediaPlayer.Create( mpId, mpType ) end -- Read owner; may be NULL local owner = net.ReadEntity() if IsValid( owner ) then mp:SetOwner( owner ) end local state = mp.net.ReadPlayerState() local queueRepeat = net.ReadBool() mp:SetQueueRepeat( queueRepeat ) local queueShuffle = net.ReadBool() mp:SetQueueShuffle( queueShuffle ) local queueLocked = net.ReadBool() mp:SetQueueLocked( queueLocked ) -- Read extended update information mp:NetReadUpdate() -- Clear old queue mp:ClearMediaQueue() -- Read queue information local count = net.ReadUInt( mp:GetQueueLimit(true) ) for i = 1, count do local media = mp.net.ReadMedia() mp:OnNetReadMedia(media) mp:AddMedia(media) end mp:QueueUpdated() mp:SetPlayerState( state ) hook.Run( "OnMediaPlayerUpdate", mp ) end net.Receive( "MEDIAPLAYER.Update", OnMediaUpdate ) local function OnMediaSet( len ) if MediaPlayer.DEBUG then print( "Received MEDIAPLAYER.Media" ) end local mpId = net.ReadString() local mp = MediaPlayer.GetById(mpId) if not mp then if MediaPlayer.DEBUG then ErrorNoHalt("Received media for invalid mediaplayer\n") print("ID: " .. tostring(mpId)) debug.Trace() end return end if mp:GetPlayerState() >= MP_STATE_PLAYING then mp:OnMediaFinished() mp:QueueUpdated() end local media = mp.net.ReadMedia() if media then local startTime = mp.net.ReadTime() media:StartTime( startTime ) mp:OnNetReadMedia(media) local state = mp:GetPlayerState() if state == MP_STATE_PLAYING then media:Play() else media:Pause() end end mp:SetMedia( media ) end net.Receive( "MEDIAPLAYER.Media", OnMediaSet ) local function OnMediaRemoved( len ) if MediaPlayer.DEBUG then print( "Received MEDIAPLAYER.Remove" ) end local mpId = net.ReadString() local mp = MediaPlayer.GetById(mpId) if not mp then return end mp:Remove() end net.Receive( "MEDIAPLAYER.Remove", OnMediaRemoved ) local function OnMediaSeek( len ) local mpId = net.ReadString() local mp = MediaPlayer.GetById(mpId) if not ( mp and (mp:GetPlayerState() >= MP_STATE_PLAYING) ) then return end local startTime = mp.net.ReadTime() if MediaPlayer.DEBUG then print( "Received MEDIAPLAYER.Seek", mpId, startTime ) end local media = mp:CurrentMedia() if media then media:StartTime( startTime ) else ErrorNoHalt('ERROR: MediaPlayer received seek message while no media is playing' .. '[' .. mpId .. ']\n') MediaPlayer.RequestUpdate( mp ) end end net.Receive( "MEDIAPLAYER.Seek", OnMediaSeek ) local function OnMediaPause( len ) local mpId = net.ReadString() local mp = MediaPlayer.GetById(mpId) if not mp then return end local state = mp.net.ReadPlayerState() if MediaPlayer.DEBUG then print( "Received MEDIAPLAYER.Pause", mpId, state ) end mp:SetPlayerState( state ) end net.Receive( "MEDIAPLAYER.Pause", OnMediaPause )
mit
litnimax/luci
modules/base/luasrc/ltn12.lua
83
11303
--[[ LuaSocket 2.0.2 license Copyright � 2004-2007 Diego Nehab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]]-- --[[ Changes made by LuCI project: * Renamed to luci.ltn12 to avoid collisions with luasocket * Added inline documentation ]]-- ----------------------------------------------------------------------------- -- LTN12 - Filters, sources, sinks and pumps. -- LuaSocket toolkit. -- Author: Diego Nehab -- RCS ID: $Id$ ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- Declare module ----------------------------------------------------------------------------- local string = require("string") local table = require("table") local base = _G --- Diego Nehab's LTN12 - Filters, sources, sinks and pumps. -- See http://lua-users.org/wiki/FiltersSourcesAndSinks for design concepts module("luci.ltn12") filter = {} source = {} sink = {} pump = {} -- 2048 seems to be better in windows... BLOCKSIZE = 2048 _VERSION = "LTN12 1.0.1" ----------------------------------------------------------------------------- -- Filter stuff ----------------------------------------------------------------------------- --- LTN12 Filter constructors -- @class module -- @name luci.ltn12.filter --- Return a high level filter that cycles a low-level filter -- by passing it each chunk and updating a context between calls. -- @param low Low-level filter -- @param ctx Context -- @param extra Extra argument passed to the low-level filter -- @return LTN12 filter function filter.cycle(low, ctx, extra) base.assert(low) return function(chunk) local ret ret, ctx = low(ctx, chunk, extra) return ret end end --- Chain a bunch of filters together. -- (thanks to Wim Couwenberg) -- @param ... filters to be chained -- @return LTN12 filter function filter.chain(...) local n = table.getn(arg) local top, index = 1, 1 local retry = "" return function(chunk) retry = chunk and retry while true do if index == top then chunk = arg[index](chunk) if chunk == "" or top == n then return chunk elseif chunk then index = index + 1 else top = top+1 index = top end else chunk = arg[index](chunk or "") if chunk == "" then index = index - 1 chunk = retry elseif chunk then if index == n then return chunk else index = index + 1 end else base.error("filter returned inappropriate nil") end end end end end ----------------------------------------------------------------------------- -- Source stuff ----------------------------------------------------------------------------- --- LTN12 Source constructors -- @class module -- @name luci.ltn12.source -- create an empty source local function empty() return nil end --- Create an empty source. -- @return LTN12 source function source.empty() return empty end --- Return a source that just outputs an error. -- @param err Error object -- @return LTN12 source function source.error(err) return function() return nil, err end end --- Create a file source. -- @param handle File handle ready for reading -- @param io_err IO error object -- @return LTN12 source function source.file(handle, io_err) if handle then return function() local chunk = handle:read(BLOCKSIZE) if not chunk then handle:close() end return chunk end else return source.error(io_err or "unable to open file") end end --- Turn a fancy source into a simple source. -- @param src fancy source -- @return LTN12 source function source.simplify(src) base.assert(src) return function() local chunk, err_or_new = src() src = err_or_new or src if not chunk then return nil, err_or_new else return chunk end end end --- Create a string source. -- @param s Data -- @return LTN12 source function source.string(s) if s then local i = 1 return function() local chunk = string.sub(s, i, i+BLOCKSIZE-1) i = i + BLOCKSIZE if chunk ~= "" then return chunk else return nil end end else return source.empty() end end --- Creates rewindable source. -- @param src LTN12 source to be made rewindable -- @return LTN12 source function source.rewind(src) base.assert(src) local t = {} return function(chunk) if not chunk then chunk = table.remove(t) if not chunk then return src() else return chunk end else t[#t+1] = chunk end end end --- Chain a source and a filter together. -- @param src LTN12 source -- @param f LTN12 filter -- @return LTN12 source function source.chain(src, f) base.assert(src and f) local last_in, last_out = "", "" local state = "feeding" local err return function() if not last_out then base.error('source is empty!', 2) end while true do if state == "feeding" then last_in, err = src() if err then return nil, err end last_out = f(last_in) if not last_out then if last_in then base.error('filter returned inappropriate nil') else return nil end elseif last_out ~= "" then state = "eating" if last_in then last_in = "" end return last_out end else last_out = f(last_in) if last_out == "" then if last_in == "" then state = "feeding" else base.error('filter returned ""') end elseif not last_out then if last_in then base.error('filter returned inappropriate nil') else return nil end else return last_out end end end end end --- Create a source that produces contents of several sources. -- Sources will be used one after the other, as if they were concatenated -- (thanks to Wim Couwenberg) -- @param ... LTN12 sources -- @return LTN12 source function source.cat(...) local src = table.remove(arg, 1) return function() while src do local chunk, err = src() if chunk then return chunk end if err then return nil, err end src = table.remove(arg, 1) end end end ----------------------------------------------------------------------------- -- Sink stuff ----------------------------------------------------------------------------- --- LTN12 sink constructors -- @class module -- @name luci.ltn12.sink --- Create a sink that stores into a table. -- @param t output table to store into -- @return LTN12 sink function sink.table(t) t = t or {} local f = function(chunk, err) if chunk then t[#t+1] = chunk end return 1 end return f, t end --- Turn a fancy sink into a simple sink. -- @param snk fancy sink -- @return LTN12 sink function sink.simplify(snk) base.assert(snk) return function(chunk, err) local ret, err_or_new = snk(chunk, err) if not ret then return nil, err_or_new end snk = err_or_new or snk return 1 end end --- Create a file sink. -- @param handle file handle to write to -- @param io_err IO error -- @return LTN12 sink function sink.file(handle, io_err) if handle then return function(chunk, err) if not chunk then handle:close() return 1 else return handle:write(chunk) end end else return sink.error(io_err or "unable to open file") end end -- creates a sink that discards data local function null() return 1 end --- Create a sink that discards data. -- @return LTN12 sink function sink.null() return null end --- Create a sink that just returns an error. -- @param err Error object -- @return LTN12 sink function sink.error(err) return function() return nil, err end end --- Chain a sink with a filter. -- @param f LTN12 filter -- @param snk LTN12 sink -- @return LTN12 sink function sink.chain(f, snk) base.assert(f and snk) return function(chunk, err) if chunk ~= "" then local filtered = f(chunk) local done = chunk and "" while true do local ret, snkerr = snk(filtered, err) if not ret then return nil, snkerr end if filtered == done then return 1 end filtered = f(done) end else return 1 end end end ----------------------------------------------------------------------------- -- Pump stuff ----------------------------------------------------------------------------- --- LTN12 pump functions -- @class module -- @name luci.ltn12.pump --- Pump one chunk from the source to the sink. -- @param src LTN12 source -- @param snk LTN12 sink -- @return Chunk of data or nil if an error occured -- @return Error object function pump.step(src, snk) local chunk, src_err = src() local ret, snk_err = snk(chunk, src_err) if chunk and ret then return 1 else return nil, src_err or snk_err end end --- Pump all data from a source to a sink, using a step function. -- @param src LTN12 source -- @param snk LTN12 sink -- @param step step function (optional) -- @return 1 if the operation succeeded otherwise nil -- @return Error object function pump.all(src, snk, step) base.assert(src and snk) step = step or pump.step while true do local ret, err = step(src, snk) if not ret then if err then return nil, err else return 1 end end end end
apache-2.0
KayMD/Illarion-Content
triggerfield/northernislands_air_661.lua
4
1249
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- INSERT INTO triggerfields VALUES (478,31,0,'triggerfield.northernislands_air_661'); -- INSERT INTO triggerfields VALUES (479,31,0,'triggerfield.northernislands_air_661'); -- INSERT INTO triggerfields VALUES (478,32,0,'triggerfield.northernislands_air_661'); -- INSERT INTO triggerfields VALUES (479,32,0,'triggerfield.northernislands_air_661'); local elementDrop = require("content.elementDrop") local M = {} function M.MoveFromField(char) -- pure air will be created elementDrop.chanceForElementDrop(char, {successItemID = 2551, failItemID = 372, failGfxID = 8}) end return M
agpl-3.0
elyasgalikeshi/renjer_bot
bot/utils.lua
646
23489
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() JSON = (loadfile "./libs/dkjson.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end --Check if this chat is realm or not function is_realm(msg) local var = false local realms = 'realms' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(realms)] then if data[tostring(realms)][tostring(msg.to.id)] then var = true end return var end end --Check if this chat is a group or not function is_group(msg) local var = false local groups = 'groups' local data = load_data(_config.moderation.data) local chat = msg.to.id if data[tostring(groups)] then if data[tostring(groups)][tostring(msg.to.id)] then var = true end return var end end function savelog(group, logtxt) local text = (os.date("[ %c ]=> "..logtxt.."\n \n")) local file = io.open("./groups/logs/"..group.."log.txt", "a") file:write(text) file:close() end function user_print_name(user) if user.print_name then return user.print_name end local text = '' if user.first_name then text = user.last_name..' ' end if user.lastname then text = text..user.last_name end return text end --Check if user is the owner of that group or not function is_owner(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_owner2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is admin or not function is_admin(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_admin2(user_id) local var = false local data = load_data(_config.moderation.data) local user = user_id local admins = 'admins' if data[tostring(admins)] then if data[tostring(admins)][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == user_id then var = true end end return var end --Check if user is the mod of that group or not function is_momod(msg) local var = false local data = load_data(_config.moderation.data) local user = msg.from.id if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['moderators'] then if data[tostring(msg.to.id)]['moderators'][tostring(user)] then var = true end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['set_owner'] then if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then var = true end end end if data['admins'] then if data['admins'][tostring(user)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end function is_momod2(user_id, group_id) local var = false local data = load_data(_config.moderation.data) local usert = user_id if data[tostring(group_id)] then if data[tostring(group_id)]['moderators'] then if data[tostring(group_id)]['moderators'][tostring(usert)] then var = true end end end if data[tostring(group_id)] then if data[tostring(group_id)]['set_owner'] then if data[tostring(group_id)]['set_owner'] == tostring(user_id) then var = true end end end if data['admins'] then if data['admins'][tostring(user_id)] then var = true end end for v,user in pairs(_config.sudo_users) do if user == usert then var = true end end return var end -- Returns the name of the sender function kick_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_owner2(user_id, chat_id) then -- Ignore admins return end local chat = 'chat#id'..chat_id local user = 'user#id'..user_id chat_del_user(chat, user, ok_cb, true) end -- Ban function ban_user(user_id, chat_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'banned:'..chat_id redis:sadd(hash, user_id) -- Kick from chat kick_user(user_id, chat_id) end -- Global ban function banall_user(user_id) if tonumber(user_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(user_id) then -- Ignore admins return end -- Save to redis local hash = 'gbanned' redis:sadd(hash, user_id) end -- Global unban function unbanall_user(user_id) --Save on redis local hash = 'gbanned' redis:srem(hash, user_id) end -- Check if user_id is banned in chat_id or not function is_banned(user_id, chat_id) --Save on redis local hash = 'banned:'..chat_id local banned = redis:sismember(hash, user_id) return banned or false end -- Check if user_id is globally banned or not function is_gbanned(user_id) --Save on redis local hash = 'gbanned' local banned = redis:sismember(hash, user_id) return banned or false end -- Returns chat_id ban list function ban_list(chat_id) local hash = 'banned:'..chat_id local list = redis:smembers(hash) local text = "Ban list !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- Returns globally ban list function banall_list() local hash = 'gbanned' local list = redis:smembers(hash) local text = "global bans !\n\n" for k,v in pairs(list) do text = text..k.." - "..v.." \n" end return text end -- /id by reply function get_message_callback_id(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id send_large_msg(chat, result.from.id) else return 'Use This in Your Groups' end end -- kick by reply for mods and owner function Kick_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end -- Kick by reply for admins function Kick_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't kick myself" end if is_admin2(result.from.id) then -- Ignore admins return end chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) else return 'Use This in Your Groups' end end --Ban by reply for admins function ban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin return "you can't kick mods,owner and admins" end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Ban by reply for admins function ban_by_reply_admins(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't ban myself" end if is_admin2(result.from.id) then -- Ignore admins return end ban_user(result.from.id, result.to.id) send_large_msg(chat, "User "..result.from.id.." Banned") else return 'Use This in Your Groups' end end -- Unban by reply function unban_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't unban myself" end send_large_msg(chat, "User "..result.from.id.." Unbanned") -- Save on redis local hash = 'banned:'..result.to.id redis:srem(hash, result.from.id) else return 'Use This in Your Groups' end end function banall_by_reply(extra, success, result) if result.to.type == 'chat' then local chat = 'chat#id'..result.to.id if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot return "I won't banall myself" end if is_admin2(result.from.id) then -- Ignore admins return end local name = user_print_name(result.from) banall_user(result.from.id) chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false) send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered") else return 'Use This in Your Groups' end end
gpl-2.0
wangtianhang/UnityLuaTest
protoBufTest/tolua_runtime_2019-09-08/luajit-2.1/src/jit/dis_arm64.lua
59
30904
---------------------------------------------------------------------------- -- LuaJIT ARM64 disassembler module. -- -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h -- -- Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com. -- Sponsored by Cisco Systems, Inc. ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- It disassembles most user-mode AArch64 instructions. -- NYI: Advanced SIMD and VFP instructions. ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local concat = table.concat local bit = require("bit") local band, bor, bxor, tohex = bit.band, bit.bor, bit.bxor, bit.tohex local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift local ror = bit.ror ------------------------------------------------------------------------------ -- Opcode maps ------------------------------------------------------------------------------ local map_adr = { -- PC-relative addressing. shift = 31, mask = 1, [0] = "adrDBx", "adrpDBx" } local map_addsubi = { -- Add/subtract immediate. shift = 29, mask = 3, [0] = "add|movDNIg", "adds|cmnD0NIg", "subDNIg", "subs|cmpD0NIg", } local map_logi = { -- Logical immediate. shift = 31, mask = 1, [0] = { shift = 22, mask = 1, [0] = { shift = 29, mask = 3, [0] = "andDNig", "orr|movDN0ig", "eorDNig", "ands|tstD0Nig" }, false -- unallocated }, { shift = 29, mask = 3, [0] = "andDNig", "orr|movDN0ig", "eorDNig", "ands|tstD0Nig" } } local map_movwi = { -- Move wide immediate. shift = 31, mask = 1, [0] = { shift = 22, mask = 1, [0] = { shift = 29, mask = 3, [0] = "movnDWRg", false, "movz|movDYRg", "movkDWRg" }, false -- unallocated }, { shift = 29, mask = 3, [0] = "movnDWRg", false, "movz|movDYRg", "movkDWRg" }, } local map_bitf = { -- Bitfield. shift = 31, mask = 1, [0] = { shift = 22, mask = 1, [0] = { shift = 29, mask = 3, [0] = "sbfm|sbfiz|sbfx|asr|sxtw|sxth|sxtbDN12w", "bfm|bfi|bfxilDN13w", "ubfm|ubfiz|ubfx|lsr|lsl|uxth|uxtbDN12w" } }, { shift = 22, mask = 1, { shift = 29, mask = 3, [0] = "sbfm|sbfiz|sbfx|asr|sxtw|sxth|sxtbDN12x", "bfm|bfi|bfxilDN13x", "ubfm|ubfiz|ubfx|lsr|lsl|uxth|uxtbDN12x" } } } local map_datai = { -- Data processing - immediate. shift = 23, mask = 7, [0] = map_adr, map_adr, map_addsubi, false, map_logi, map_movwi, map_bitf, { shift = 15, mask = 0x1c0c1, [0] = "extr|rorDNM4w", [0x10080] = "extr|rorDNM4x", [0x10081] = "extr|rorDNM4x" } } local map_logsr = { -- Logical, shifted register. shift = 31, mask = 1, [0] = { shift = 15, mask = 1, [0] = { shift = 29, mask = 3, [0] = { shift = 21, mask = 7, [0] = "andDNMSg", "bicDNMSg", "andDNMSg", "bicDNMSg", "andDNMSg", "bicDNMSg", "andDNMg", "bicDNMg" }, { shift = 21, mask = 7, [0] ="orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0Mg", "orn|mvnDN0Mg" }, { shift = 21, mask = 7, [0] = "eorDNMSg", "eonDNMSg", "eorDNMSg", "eonDNMSg", "eorDNMSg", "eonDNMSg", "eorDNMg", "eonDNMg" }, { shift = 21, mask = 7, [0] = "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMg", "bicsDNMg" } }, false -- unallocated }, { shift = 29, mask = 3, [0] = { shift = 21, mask = 7, [0] = "andDNMSg", "bicDNMSg", "andDNMSg", "bicDNMSg", "andDNMSg", "bicDNMSg", "andDNMg", "bicDNMg" }, { shift = 21, mask = 7, [0] = "orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0MSg", "orn|mvnDN0MSg", "orr|movDN0Mg", "orn|mvnDN0Mg" }, { shift = 21, mask = 7, [0] = "eorDNMSg", "eonDNMSg", "eorDNMSg", "eonDNMSg", "eorDNMSg", "eonDNMSg", "eorDNMg", "eonDNMg" }, { shift = 21, mask = 7, [0] = "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMSg", "bicsDNMSg", "ands|tstD0NMg", "bicsDNMg" } } } local map_assh = { shift = 31, mask = 1, [0] = { shift = 15, mask = 1, [0] = { shift = 29, mask = 3, [0] = { shift = 22, mask = 3, [0] = "addDNMSg", "addDNMSg", "addDNMSg", "addDNMg" }, { shift = 22, mask = 3, [0] = "adds|cmnD0NMSg", "adds|cmnD0NMSg", "adds|cmnD0NMSg", "adds|cmnD0NMg" }, { shift = 22, mask = 3, [0] = "sub|negDN0MSg", "sub|negDN0MSg", "sub|negDN0MSg", "sub|negDN0Mg" }, { shift = 22, mask = 3, [0] = "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0Mzg" }, }, false -- unallocated }, { shift = 29, mask = 3, [0] = { shift = 22, mask = 3, [0] = "addDNMSg", "addDNMSg", "addDNMSg", "addDNMg" }, { shift = 22, mask = 3, [0] = "adds|cmnD0NMSg", "adds|cmnD0NMSg", "adds|cmnD0NMSg", "adds|cmnD0NMg" }, { shift = 22, mask = 3, [0] = "sub|negDN0MSg", "sub|negDN0MSg", "sub|negDN0MSg", "sub|negDN0Mg" }, { shift = 22, mask = 3, [0] = "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0MzSg", "subs|cmp|negsD0N0Mzg" } } } local map_addsubsh = { -- Add/subtract, shifted register. shift = 22, mask = 3, [0] = map_assh, map_assh, map_assh } local map_addsubex = { -- Add/subtract, extended register. shift = 22, mask = 3, [0] = { shift = 29, mask = 3, [0] = "addDNMXg", "adds|cmnD0NMXg", "subDNMXg", "subs|cmpD0NMzXg", } } local map_addsubc = { -- Add/subtract, with carry. shift = 10, mask = 63, [0] = { shift = 29, mask = 3, [0] = "adcDNMg", "adcsDNMg", "sbc|ngcDN0Mg", "sbcs|ngcsDN0Mg", } } local map_ccomp = { shift = 4, mask = 1, [0] = { shift = 10, mask = 3, [0] = { -- Conditional compare register. shift = 29, mask = 3, "ccmnNMVCg", false, "ccmpNMVCg", }, [2] = { -- Conditional compare immediate. shift = 29, mask = 3, "ccmnN5VCg", false, "ccmpN5VCg", } } } local map_csel = { -- Conditional select. shift = 11, mask = 1, [0] = { shift = 10, mask = 1, [0] = { shift = 29, mask = 3, [0] = "cselDNMzCg", false, "csinv|cinv|csetmDNMcg", false, }, { shift = 29, mask = 3, [0] = "csinc|cinc|csetDNMcg", false, "csneg|cnegDNMcg", false, } } } local map_data1s = { -- Data processing, 1 source. shift = 29, mask = 1, [0] = { shift = 31, mask = 1, [0] = { shift = 10, mask = 0x7ff, [0] = "rbitDNg", "rev16DNg", "revDNw", false, "clzDNg", "clsDNg" }, { shift = 10, mask = 0x7ff, [0] = "rbitDNg", "rev16DNg", "rev32DNx", "revDNx", "clzDNg", "clsDNg" } } } local map_data2s = { -- Data processing, 2 sources. shift = 29, mask = 1, [0] = { shift = 10, mask = 63, false, "udivDNMg", "sdivDNMg", false, false, false, false, "lslDNMg", "lsrDNMg", "asrDNMg", "rorDNMg" } } local map_data3s = { -- Data processing, 3 sources. shift = 29, mask = 7, [0] = { shift = 21, mask = 7, [0] = { shift = 15, mask = 1, [0] = "madd|mulDNMA0g", "msub|mnegDNMA0g" } }, false, false, false, { shift = 15, mask = 1, [0] = { shift = 21, mask = 7, [0] = "madd|mulDNMA0g", "smaddl|smullDxNMwA0x", "smulhDNMx", false, false, "umaddl|umullDxNMwA0x", "umulhDNMx" }, { shift = 21, mask = 7, [0] = "msub|mnegDNMA0g", "smsubl|smneglDxNMwA0x", false, false, false, "umsubl|umneglDxNMwA0x" } } } local map_datar = { -- Data processing, register. shift = 28, mask = 1, [0] = { shift = 24, mask = 1, [0] = map_logsr, { shift = 21, mask = 1, [0] = map_addsubsh, map_addsubex } }, { shift = 21, mask = 15, [0] = map_addsubc, false, map_ccomp, false, map_csel, false, { shift = 30, mask = 1, [0] = map_data2s, map_data1s }, false, map_data3s, map_data3s, map_data3s, map_data3s, map_data3s, map_data3s, map_data3s, map_data3s } } local map_lrl = { -- Load register, literal. shift = 26, mask = 1, [0] = { shift = 30, mask = 3, [0] = "ldrDwB", "ldrDxB", "ldrswDxB" }, { shift = 30, mask = 3, [0] = "ldrDsB", "ldrDdB" } } local map_lsriind = { -- Load/store register, immediate pre/post-indexed. shift = 30, mask = 3, [0] = { shift = 26, mask = 1, [0] = { shift = 22, mask = 3, [0] = "strbDwzL", "ldrbDwzL", "ldrsbDxzL", "ldrsbDwzL" } }, { shift = 26, mask = 1, [0] = { shift = 22, mask = 3, [0] = "strhDwzL", "ldrhDwzL", "ldrshDxzL", "ldrshDwzL" } }, { shift = 26, mask = 1, [0] = { shift = 22, mask = 3, [0] = "strDwzL", "ldrDwzL", "ldrswDxzL" }, { shift = 22, mask = 3, [0] = "strDszL", "ldrDszL" } }, { shift = 26, mask = 1, [0] = { shift = 22, mask = 3, [0] = "strDxzL", "ldrDxzL" }, { shift = 22, mask = 3, [0] = "strDdzL", "ldrDdzL" } } } local map_lsriro = { shift = 21, mask = 1, [0] = { -- Load/store register immediate. shift = 10, mask = 3, [0] = { -- Unscaled immediate. shift = 26, mask = 1, [0] = { shift = 30, mask = 3, [0] = { shift = 22, mask = 3, [0] = "sturbDwK", "ldurbDwK" }, { shift = 22, mask = 3, [0] = "sturhDwK", "ldurhDwK" }, { shift = 22, mask = 3, [0] = "sturDwK", "ldurDwK" }, { shift = 22, mask = 3, [0] = "sturDxK", "ldurDxK" } } }, map_lsriind, false, map_lsriind }, { -- Load/store register, register offset. shift = 10, mask = 3, [2] = { shift = 26, mask = 1, [0] = { shift = 30, mask = 3, [0] = { shift = 22, mask = 3, [0] = "strbDwO", "ldrbDwO", "ldrsbDxO", "ldrsbDwO" }, { shift = 22, mask = 3, [0] = "strhDwO", "ldrhDwO", "ldrshDxO", "ldrshDwO" }, { shift = 22, mask = 3, [0] = "strDwO", "ldrDwO", "ldrswDxO" }, { shift = 22, mask = 3, [0] = "strDxO", "ldrDxO" } }, { shift = 30, mask = 3, [2] = { shift = 22, mask = 3, [0] = "strDsO", "ldrDsO" }, [3] = { shift = 22, mask = 3, [0] = "strDdO", "ldrDdO" } } } } } local map_lsp = { -- Load/store register pair, offset. shift = 22, mask = 1, [0] = { shift = 30, mask = 3, [0] = { shift = 26, mask = 1, [0] = "stpDzAzwP", "stpDzAzsP", }, { shift = 26, mask = 1, "stpDzAzdP" }, { shift = 26, mask = 1, [0] = "stpDzAzxP" } }, { shift = 30, mask = 3, [0] = { shift = 26, mask = 1, [0] = "ldpDzAzwP", "ldpDzAzsP", }, { shift = 26, mask = 1, [0] = "ldpswDAxP", "ldpDzAzdP" }, { shift = 26, mask = 1, [0] = "ldpDzAzxP" } } } local map_ls = { -- Loads and stores. shift = 24, mask = 0x31, [0x10] = map_lrl, [0x30] = map_lsriro, [0x20] = { shift = 23, mask = 3, map_lsp, map_lsp, map_lsp }, [0x21] = { shift = 23, mask = 3, map_lsp, map_lsp, map_lsp }, [0x31] = { shift = 26, mask = 1, [0] = { shift = 30, mask = 3, [0] = { shift = 22, mask = 3, [0] = "strbDwzU", "ldrbDwzU" }, { shift = 22, mask = 3, [0] = "strhDwzU", "ldrhDwzU" }, { shift = 22, mask = 3, [0] = "strDwzU", "ldrDwzU" }, { shift = 22, mask = 3, [0] = "strDxzU", "ldrDxzU" } }, { shift = 30, mask = 3, [2] = { shift = 22, mask = 3, [0] = "strDszU", "ldrDszU" }, [3] = { shift = 22, mask = 3, [0] = "strDdzU", "ldrDdzU" } } }, } local map_datafp = { -- Data processing, SIMD and FP. shift = 28, mask = 7, { -- 001 shift = 24, mask = 1, [0] = { shift = 21, mask = 1, { shift = 10, mask = 3, [0] = { shift = 12, mask = 1, [0] = { shift = 13, mask = 1, [0] = { shift = 14, mask = 1, [0] = { shift = 15, mask = 1, [0] = { -- FP/int conversion. shift = 31, mask = 1, [0] = { shift = 16, mask = 0xff, [0x20] = "fcvtnsDwNs", [0x21] = "fcvtnuDwNs", [0x22] = "scvtfDsNw", [0x23] = "ucvtfDsNw", [0x24] = "fcvtasDwNs", [0x25] = "fcvtauDwNs", [0x26] = "fmovDwNs", [0x27] = "fmovDsNw", [0x28] = "fcvtpsDwNs", [0x29] = "fcvtpuDwNs", [0x30] = "fcvtmsDwNs", [0x31] = "fcvtmuDwNs", [0x38] = "fcvtzsDwNs", [0x39] = "fcvtzuDwNs", [0x60] = "fcvtnsDwNd", [0x61] = "fcvtnuDwNd", [0x62] = "scvtfDdNw", [0x63] = "ucvtfDdNw", [0x64] = "fcvtasDwNd", [0x65] = "fcvtauDwNd", [0x68] = "fcvtpsDwNd", [0x69] = "fcvtpuDwNd", [0x70] = "fcvtmsDwNd", [0x71] = "fcvtmuDwNd", [0x78] = "fcvtzsDwNd", [0x79] = "fcvtzuDwNd" }, { shift = 16, mask = 0xff, [0x20] = "fcvtnsDxNs", [0x21] = "fcvtnuDxNs", [0x22] = "scvtfDsNx", [0x23] = "ucvtfDsNx", [0x24] = "fcvtasDxNs", [0x25] = "fcvtauDxNs", [0x28] = "fcvtpsDxNs", [0x29] = "fcvtpuDxNs", [0x30] = "fcvtmsDxNs", [0x31] = "fcvtmuDxNs", [0x38] = "fcvtzsDxNs", [0x39] = "fcvtzuDxNs", [0x60] = "fcvtnsDxNd", [0x61] = "fcvtnuDxNd", [0x62] = "scvtfDdNx", [0x63] = "ucvtfDdNx", [0x64] = "fcvtasDxNd", [0x65] = "fcvtauDxNd", [0x66] = "fmovDxNd", [0x67] = "fmovDdNx", [0x68] = "fcvtpsDxNd", [0x69] = "fcvtpuDxNd", [0x70] = "fcvtmsDxNd", [0x71] = "fcvtmuDxNd", [0x78] = "fcvtzsDxNd", [0x79] = "fcvtzuDxNd" } } }, { -- FP data-processing, 1 source. shift = 31, mask = 1, [0] = { shift = 22, mask = 3, [0] = { shift = 15, mask = 63, [0] = "fmovDNf", "fabsDNf", "fnegDNf", "fsqrtDNf", false, "fcvtDdNs", false, false, "frintnDNf", "frintpDNf", "frintmDNf", "frintzDNf", "frintaDNf", false, "frintxDNf", "frintiDNf", }, { shift = 15, mask = 63, [0] = "fmovDNf", "fabsDNf", "fnegDNf", "fsqrtDNf", "fcvtDsNd", false, false, false, "frintnDNf", "frintpDNf", "frintmDNf", "frintzDNf", "frintaDNf", false, "frintxDNf", "frintiDNf", } } } }, { -- FP compare. shift = 31, mask = 1, [0] = { shift = 14, mask = 3, [0] = { shift = 23, mask = 1, [0] = { shift = 0, mask = 31, [0] = "fcmpNMf", [8] = "fcmpNZf", [16] = "fcmpeNMf", [24] = "fcmpeNZf", } } } } }, { -- FP immediate. shift = 31, mask = 1, [0] = { shift = 5, mask = 31, [0] = { shift = 23, mask = 1, [0] = "fmovDFf" } } } }, { -- FP conditional compare. shift = 31, mask = 1, [0] = { shift = 23, mask = 1, [0] = { shift = 4, mask = 1, [0] = "fccmpNMVCf", "fccmpeNMVCf" } } }, { -- FP data-processing, 2 sources. shift = 31, mask = 1, [0] = { shift = 23, mask = 1, [0] = { shift = 12, mask = 15, [0] = "fmulDNMf", "fdivDNMf", "faddDNMf", "fsubDNMf", "fmaxDNMf", "fminDNMf", "fmaxnmDNMf", "fminnmDNMf", "fnmulDNMf" } } }, { -- FP conditional select. shift = 31, mask = 1, [0] = { shift = 23, mask = 1, [0] = "fcselDNMCf" } } } }, { -- FP data-processing, 3 sources. shift = 31, mask = 1, [0] = { shift = 15, mask = 1, [0] = { shift = 21, mask = 5, [0] = "fmaddDNMAf", "fnmaddDNMAf" }, { shift = 21, mask = 5, [0] = "fmsubDNMAf", "fnmsubDNMAf" } } } } } local map_br = { -- Branches, exception generating and system instructions. shift = 29, mask = 7, [0] = "bB", { -- Compare & branch, immediate. shift = 24, mask = 3, [0] = "cbzDBg", "cbnzDBg", "tbzDTBw", "tbnzDTBw" }, { -- Conditional branch, immediate. shift = 24, mask = 3, [0] = { shift = 4, mask = 1, [0] = { shift = 0, mask = 15, [0] = "beqB", "bneB", "bhsB", "bloB", "bmiB", "bplB", "bvsB", "bvcB", "bhiB", "blsB", "bgeB", "bltB", "bgtB", "bleB", "balB" } } }, false, "blB", { -- Compare & branch, immediate. shift = 24, mask = 3, [0] = "cbzDBg", "cbnzDBg", "tbzDTBx", "tbnzDTBx" }, { shift = 24, mask = 3, [0] = { -- Exception generation. shift = 0, mask = 0xe0001f, [0x200000] = "brkW" }, { -- System instructions. shift = 0, mask = 0x3fffff, [0x03201f] = "nop" }, { -- Unconditional branch, register. shift = 0, mask = 0xfffc1f, [0x1f0000] = "brNx", [0x3f0000] = "blrNx", [0x5f0000] = "retNx" }, } } local map_init = { shift = 25, mask = 15, [0] = false, false, false, false, map_ls, map_datar, map_ls, map_datafp, map_datai, map_datai, map_br, map_br, map_ls, map_datar, map_ls, map_datafp } ------------------------------------------------------------------------------ local map_regs = { x = {}, w = {}, d = {}, s = {} } for i=0,30 do map_regs.x[i] = "x"..i map_regs.w[i] = "w"..i map_regs.d[i] = "d"..i map_regs.s[i] = "s"..i end map_regs.x[31] = "sp" map_regs.w[31] = "wsp" map_regs.d[31] = "d31" map_regs.s[31] = "s31" local map_cond = { [0] = "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "al", } local map_shift = { [0] = "lsl", "lsr", "asr", } local map_extend = { [0] = "uxtb", "uxth", "uxtw", "uxtx", "sxtb", "sxth", "sxtw", "sxtx", } ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local pos = ctx.pos local extra = "" if ctx.rel then local sym = ctx.symtab[ctx.rel] if sym then extra = "\t->"..sym end end if ctx.hexdump > 0 then ctx.out(format("%08x %s %-5s %s%s\n", ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) else ctx.out(format("%08x %-5s %s%s\n", ctx.addr+pos, text, concat(operands, ", "), extra)) end ctx.pos = pos + 4 end -- Fallback for unknown opcodes. local function unknown(ctx) return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) end local function match_reg(p, pat, regnum) return map_regs[match(pat, p.."%w-([xwds])")][regnum] end local function fmt_hex32(x) if x < 0 then return tohex(x) else return format("%x", x) end end local imm13_rep = { 0x55555555, 0x11111111, 0x01010101, 0x00010001, 0x00000001 } local function decode_imm13(op) local imms = band(rshift(op, 10), 63) local immr = band(rshift(op, 16), 63) if band(op, 0x00400000) == 0 then local len = 5 if imms >= 56 then if imms >= 60 then len = 1 else len = 2 end elseif imms >= 48 then len = 3 elseif imms >= 32 then len = 4 end local l = lshift(1, len)-1 local s = band(imms, l) local r = band(immr, l) local imm = ror(rshift(-1, 31-s), r) if len ~= 5 then imm = band(imm, lshift(1, l)-1) + rshift(imm, 31-l) end imm = imm * imm13_rep[len] local ix = fmt_hex32(imm) if rshift(op, 31) ~= 0 then return ix..tohex(imm) else return ix end else local lo, hi = -1, 0 if imms < 32 then lo = rshift(-1, 31-imms) else hi = rshift(-1, 63-imms) end if immr ~= 0 then lo, hi = ror(lo, immr), ror(hi, immr) local x = immr == 32 and 0 or band(bxor(lo, hi), lshift(-1, 32-immr)) lo, hi = bxor(lo, x), bxor(hi, x) if immr >= 32 then lo, hi = hi, lo end end if hi ~= 0 then return fmt_hex32(hi)..tohex(lo) else return fmt_hex32(lo) end end end local function parse_immpc(op, name) if name == "b" or name == "bl" then return arshift(lshift(op, 6), 4) elseif name == "adr" or name == "adrp" then local immlo = band(rshift(op, 29), 3) local immhi = lshift(arshift(lshift(op, 8), 13), 2) return bor(immhi, immlo) elseif name == "tbz" or name == "tbnz" then return lshift(arshift(lshift(op, 13), 18), 2) else return lshift(arshift(lshift(op, 8), 13), 2) end end local function parse_fpimm8(op) local sign = band(op, 0x100000) == 0 and 1 or -1 local exp = bxor(rshift(arshift(lshift(op, 12), 5), 24), 0x80) - 131 local frac = 16+band(rshift(op, 13), 15) return sign * frac * 2^exp end local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false end if immr == 0 then if sf == 0 and (imms == 7 or imms == 15) then return false end if sf ~= 0 and uns == 0 and (imms == 7 or imms == 15 or imms == 31) then return false end end return true end -- Disassemble a single instruction. local function disass_ins(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) local operands = {} local suffix = "" local last, name, pat local map_reg ctx.op = op ctx.rel = nil last = nil local opat opat = map_init[band(rshift(op, 25), 15)] while type(opat) ~= "string" do if not opat then return unknown(ctx) end opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ end name, pat = match(opat, "^([a-z0-9]*)(.*)") local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") if altname then pat = pat2 end if sub(pat, 1, 1) == "." then local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)") suffix = suffix..s2 pat = p2 end local rt = match(pat, "[gf]") if rt then if rt == "g" then map_reg = band(op, 0x80000000) ~= 0 and map_regs.x or map_regs.w else map_reg = band(op, 0x400000) ~= 0 and map_regs.d or map_regs.s end end local second0, immr for p in gmatch(pat, ".") do local x = nil if p == "D" then local regnum = band(op, 31) x = rt and map_reg[regnum] or match_reg(p, pat, regnum) elseif p == "N" then local regnum = band(rshift(op, 5), 31) x = rt and map_reg[regnum] or match_reg(p, pat, regnum) elseif p == "M" then local regnum = band(rshift(op, 16), 31) x = rt and map_reg[regnum] or match_reg(p, pat, regnum) elseif p == "A" then local regnum = band(rshift(op, 10), 31) x = rt and map_reg[regnum] or match_reg(p, pat, regnum) elseif p == "B" then local addr = ctx.addr + pos + parse_immpc(op, name) ctx.rel = addr x = "0x"..tohex(addr) elseif p == "T" then x = bor(band(rshift(op, 26), 32), band(rshift(op, 19), 31)) elseif p == "V" then x = band(op, 15) elseif p == "C" then x = map_cond[band(rshift(op, 12), 15)] elseif p == "c" then local rn = band(rshift(op, 5), 31) local rm = band(rshift(op, 16), 31) local cond = band(rshift(op, 12), 15) local invc = bxor(cond, 1) x = map_cond[cond] if altname and cond ~= 14 and cond ~= 15 then local a1, a2 = match(altname, "([^|]*)|(.*)") if rn == rm then local n = #operands operands[n] = nil x = map_cond[invc] if rn ~= 31 then if a1 then name = a1 else name = altname end else operands[n-1] = nil name = a2 end end end elseif p == "W" then x = band(rshift(op, 5), 0xffff) elseif p == "Y" then x = band(rshift(op, 5), 0xffff) local hw = band(rshift(op, 21), 3) if altname and (hw == 0 or x ~= 0) then name = altname end elseif p == "L" then local rn = map_regs.x[band(rshift(op, 5), 31)] local imm9 = arshift(lshift(op, 11), 23) if band(op, 0x800) ~= 0 then x = "["..rn..", #"..imm9.."]!" else x = "["..rn.."], #"..imm9 end elseif p == "U" then local rn = map_regs.x[band(rshift(op, 5), 31)] local sz = band(rshift(op, 30), 3) local imm12 = lshift(arshift(lshift(op, 10), 20), sz) if imm12 ~= 0 then x = "["..rn..", #"..imm12.."]" else x = "["..rn.."]" end elseif p == "K" then local rn = map_regs.x[band(rshift(op, 5), 31)] local imm9 = arshift(lshift(op, 11), 23) if imm9 ~= 0 then x = "["..rn..", #"..imm9.."]" else x = "["..rn.."]" end elseif p == "O" then local rn, rm = map_regs.x[band(rshift(op, 5), 31)] local m = band(rshift(op, 13), 1) if m == 0 then rm = map_regs.w[band(rshift(op, 16), 31)] else rm = map_regs.x[band(rshift(op, 16), 31)] end x = "["..rn..", "..rm local opt = band(rshift(op, 13), 7) local s = band(rshift(op, 12), 1) local sz = band(rshift(op, 30), 3) -- extension to be applied if opt == 3 then if s == 0 then x = x.."]" else x = x..", lsl #"..sz.."]" end elseif opt == 2 or opt == 6 or opt == 7 then if s == 0 then x = x..", "..map_extend[opt].."]" else x = x..", "..map_extend[opt].." #"..sz.."]" end else x = x.."]" end elseif p == "P" then local opcv, sh = rshift(op, 26), 2 if opcv >= 0x2a then sh = 4 elseif opcv >= 0x1b then sh = 3 end local imm7 = lshift(arshift(lshift(op, 10), 25), sh) local rn = map_regs.x[band(rshift(op, 5), 31)] local ind = band(rshift(op, 23), 3) if ind == 1 then x = "["..rn.."], #"..imm7 elseif ind == 2 then if imm7 == 0 then x = "["..rn.."]" else x = "["..rn..", #"..imm7.."]" end elseif ind == 3 then x = "["..rn..", #"..imm7.."]!" end elseif p == "I" then local shf = band(rshift(op, 22), 3) local imm12 = band(rshift(op, 10), 0x0fff) local rn, rd = band(rshift(op, 5), 31), band(op, 31) if altname == "mov" and shf == 0 and imm12 == 0 and (rn == 31 or rd == 31) then name = altname x = nil elseif shf == 0 then x = imm12 elseif shf == 1 then x = imm12..", lsl #12" end elseif p == "i" then x = "#0x"..decode_imm13(op) elseif p == "1" then immr = band(rshift(op, 16), 63) x = immr elseif p == "2" then x = band(rshift(op, 10), 63) if altname then local a1, a2, a3, a4, a5, a6 = match(altname, "([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|(.*)") local sf = band(rshift(op, 26), 32) local uns = band(rshift(op, 30), 1) if prefer_bfx(sf, uns, x, immr) then name = a2 x = x - immr + 1 elseif immr == 0 and x == 7 then local n = #operands operands[n] = nil if sf ~= 0 then operands[n-1] = gsub(operands[n-1], "x", "w") end last = operands[n-1] name = a6 x = nil elseif immr == 0 and x == 15 then local n = #operands operands[n] = nil if sf ~= 0 then operands[n-1] = gsub(operands[n-1], "x", "w") end last = operands[n-1] name = a5 x = nil elseif x == 31 or x == 63 then if x == 31 and immr == 0 and name == "sbfm" then name = a4 local n = #operands operands[n] = nil if sf ~= 0 then operands[n-1] = gsub(operands[n-1], "x", "w") end last = operands[n-1] else name = a3 end x = nil elseif band(x, 31) ~= 31 and immr == x+1 and name == "ubfm" then name = a4 last = "#"..(sf+32 - immr) operands[#operands] = last x = nil elseif x < immr then name = a1 last = "#"..(sf+32 - immr) operands[#operands] = last x = x + 1 end end elseif p == "3" then x = band(rshift(op, 10), 63) if altname then local a1, a2 = match(altname, "([^|]*)|(.*)") if x < immr then name = a1 local sf = band(rshift(op, 26), 32) last = "#"..(sf+32 - immr) operands[#operands] = last x = x + 1 elseif x >= immr then name = a2 x = x - immr + 1 end end elseif p == "4" then x = band(rshift(op, 10), 63) local rn = band(rshift(op, 5), 31) local rm = band(rshift(op, 16), 31) if altname and rn == rm then local n = #operands operands[n] = nil last = operands[n-1] name = altname end elseif p == "5" then x = band(rshift(op, 16), 31) elseif p == "S" then x = band(rshift(op, 10), 63) if x == 0 then x = nil else x = map_shift[band(rshift(op, 22), 3)].." #"..x end elseif p == "X" then local opt = band(rshift(op, 13), 7) -- Width specifier <R>. if opt ~= 3 and opt ~= 7 then last = map_regs.w[band(rshift(op, 16), 31)] operands[#operands] = last end x = band(rshift(op, 10), 7) -- Extension. if opt == 2 + band(rshift(op, 31), 1) and band(rshift(op, second0 and 5 or 0), 31) == 31 then if x == 0 then x = nil else x = "lsl #"..x end else if x == 0 then x = map_extend[band(rshift(op, 13), 7)] else x = map_extend[band(rshift(op, 13), 7)].." #"..x end end elseif p == "R" then x = band(rshift(op,21), 3) if x == 0 then x = nil else x = "lsl #"..x*16 end elseif p == "z" then local n = #operands if operands[n] == "sp" then operands[n] = "xzr" elseif operands[n] == "wsp" then operands[n] = "wzr" end elseif p == "Z" then x = 0 elseif p == "F" then x = parse_fpimm8(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. elseif p == "0" then if last == "sp" or last == "wsp" then local n = #operands operands[n] = nil last = operands[n-1] if altname then local a1, a2 = match(altname, "([^|]*)|(.*)") if not a1 then name = altname elseif second0 then name, altname = a2, a1 else name, altname = a1, a2 end end end second0 = true else assert(false) end if x then last = x if type(x) == "number" then x = "#"..x end operands[#operands+1] = x end end return putop(ctx, name..suffix, operands) end ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code ctx.pos = ofs ctx.rel = nil while ctx.pos < stop do disass_ins(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create(code, addr, out) local ctx = {} ctx.code = code ctx.addr = addr or 0 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 8 return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass(code, addr, out) create(code, addr, out):disass() end -- Return register name for RID. local function regname(r) if r < 32 then return map_regs.x[r] end return map_regs.d[r-32] end -- Public module functions. return { create = create, disass = disass, regname = regname }
mit
safavi1381/Mr_bot
plugins/twitter_send.lua
627
1555
do local OAuth = require "OAuth" local consumer_key = "" local consumer_secret = "" local access_token = "" local access_token_secret = "" local client = OAuth.new(consumer_key, consumer_secret, { RequestToken = "https://api.twitter.com/oauth/request_token", AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"}, AccessToken = "https://api.twitter.com/oauth/access_token" }, { OAuthToken = access_token, OAuthTokenSecret = access_token_secret }) function run(msg, matches) if consumer_key:isempty() then return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua" end if consumer_secret:isempty() then return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua" end if access_token:isempty() then return "Twitter Access Token is empty, write it in plugins/twitter_send.lua" end if access_token_secret:isempty() then return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua" end if not is_sudo(msg) then return "You aren't allowed to send tweets" end local response_code, response_headers, response_status_line, response_body = client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", { status = matches[1] }) if response_code ~= 200 then return "Error: "..response_code end return "Tweet sent" end return { description = "Sends a tweet", usage = "!tw [text]: Sends the Tweet with the configured account.", patterns = {"^!tw (.+)"}, run = run } end
gpl-2.0
gajop/Zero-K
LuaUI/Widgets/unit_ghostSite.lua
3
7194
-- $Id$ local versionNumber = "1.03" local devCompat = Spring.Utilities.IsCurrentVersionNewerThan(100, 0) function widget:GetInfo() return { name = "Ghost Site", desc = "[v" .. string.format("%s", versionNumber) .. "] Displays ghosted buildings in progress and features", author = "very_bad_soldier", date = "April 7, 2009", license = "GNU GPL v2", layer = 0, enabled = true } end -- CONFIGURATION local updateInt = 1 --seconds for the ::update loop -- END OF CONFIG local PARAM_DEFID = 4 local PARAM_TEAMID = 5 local PARAM_TEXTURE = 6 local PARAM_RADIUS = 7 local PARAM_FACING = 8 local updateTimer = 0 local ghostSites = {} local ghostFeatures = {} local scanForRemovalUnits = {} local scanForRemovalFeatures = {} local dontCheckFeatures = {} local gaiaTeamID = ((Game.version:find('91.0') == 1)) and -1 or Spring.GetGaiaTeamID() local shaderObj function InitShader() local shaderTemplate = include("Widgets/Shaders/default_tint.lua") local shader = gl.CreateShader(shaderTemplate) local errors = gl.GetShaderLog(shader) if errors ~= "" then Spring.Echo(errors) return end shaderObj = { shader = shader, teamColorID = gl.GetUniformLocation(shader, "teamColor"), tint = gl.GetUniformLocation(shader, "tint") } end local function DrawGhostFeatures() gl.Color(1.0, 1.0, 1.0, 0.35) --gl.Texture(0,"$units1") --.3do texture atlas for .3do model --gl.Texture(1,"$units1") gl.TexEnv(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, 34160) --34160 = GL_COMBINE_RGB_ARB --use the alpha given by glColor for the outgoing alpha, else it would interpret the teamcolor channel as alpha one and make model transparent. gl.TexEnv(GL.TEXTURE_ENV, 34162, GL.REPLACE) --34162 = GL_COMBINE_ALPHA gl.TexEnv(GL.TEXTURE_ENV, 34184, 34167) --34184 = GL_SOURCE0_ALPHA_ARB, 34167 = GL_PRIMARY_COLOR_ARB --------------------------Draw------------------------------------------------------------- local lastTexture = "" for featureID, ghost in pairs(ghostFeatures) do local x, y, z = ghost[1], ghost[2], ghost[3] local _, losState = Spring.GetPositionLosState(x, y, z) if not losState and Spring.IsSphereInView(x,y,z,ghost[PARAM_RADIUS]) then --glow effect? --gl.Blending(GL.SRC_ALPHA, GL.ONE) if (lastTexture ~= ghost[PARAM_TEXTURE]) then lastTexture = ghost[PARAM_TEXTURE] gl.Texture(0, lastTexture) -- no 3do support! end gl.PushMatrix() gl.Translate(x, y, z) gl.FeatureShape(ghost[PARAM_DEFID], ghost[PARAM_TEAMID], false, true, false) gl.PopMatrix() else scanForRemovalFeatures[featureID] = true end end --------------------------Clean up------------------------------------------------------------- gl.TexEnv(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, 8448) --8448 = GL_MODULATE --use the alpha given by glColor for the outgoing alpha. gl.TexEnv(GL.TEXTURE_ENV, 34162, 8448) --34162 = GL_COMBINE_ALPHA, 8448 = GL_MODULATE --gl.TexEnv(GL.TEXTURE_ENV, 34184, 5890) --34184 = GL_SOURCE0_ALPHA_ARB, 5890 = GL_TEXTURE end local function DrawGhostSites() gl.Color(0.3, 1.0, 0.3, 0.25) gl.DepthTest(true) for unitID, ghost in pairs(ghostSites) do local x, y, z = ghost[1], ghost[2], ghost[3] local _, losState = Spring.GetPositionLosState(x, y, z) if not losState and Spring.IsSphereInView(x,y,z,ghost[PARAM_RADIUS]) then --glow effect? --gl.Blending(GL.SRC_ALPHA, GL.ONE) local ghostTeamColor = {Spring.GetTeamColor(ghost[PARAM_TEAMID])} gl.PushMatrix() gl.Translate(x, y, z) gl.Rotate(ghost[PARAM_FACING], 0, 1, 0) if devCompat then gl.UseShader(shaderObj.shader) gl.Uniform(shaderObj.teamColorID, ghostTeamColor[1], ghostTeamColor[2], ghostTeamColor[3], 0.25) gl.Uniform(shaderObj.tint, 0.1, 1, 0.2) gl.UnitShapeTextures(ghost[PARAM_DEFID], true) gl.UnitShape(ghost[PARAM_DEFID], ghost[PARAM_TEAMID], true) gl.UnitShapeTextures(ghost[PARAM_DEFID], false) else gl.UnitShape(ghost[PARAM_DEFID], ghost[PARAM_TEAMID]) end gl.UseShader(0) gl.PopMatrix() else scanForRemovalUnits[unitID] = true end end end local function ScanFeatures() for _, fID in ipairs(Spring.GetAllFeatures()) do if not (dontCheckFeatures[fID] or ghostFeatures[fID]) then local fAllyID = Spring.GetFeatureAllyTeam(fID) local fTeamID = Spring.GetFeatureTeam(fID) if (fTeamID ~= gaiaTeamID and fAllyID and fAllyID >= 0) then local fDefId = Spring.GetFeatureDefID(fID) local x, y, z = Spring.GetFeaturePosition(fID) ghostFeatures[fID] = { x, y, z, fDefId, fTeamID, "%-"..fDefId..":0", FeatureDefs[fDefId].radius + 100 } else dontCheckFeatures[fID] = true end end end end local function DeleteGhostFeatures() if not next(scanForRemovalFeatures) then return end for featureID in pairs(scanForRemovalFeatures) do local ghost = ghostFeatures[featureID] local x, y, z = ghost[1], ghost[2], ghost[3] local _, losState = Spring.GetPositionLosState(x, y, z) local featDefID = Spring.GetFeatureDefID(featureID) if (not featDefID and losState) then ghostFeatures[featureID] = nil end end scanForRemovalFeatures = {} end local function DeleteGhostSites() if not next(scanForRemovalUnits) then return end for unitID in pairs(scanForRemovalUnits) do local ghost = ghostSites[unitID] local x, y, z = ghost[1], ghost[2], ghost[3] local _, losState = Spring.GetPositionLosState(x, y, z) local udefID = Spring.GetUnitDefID(unitID) local _,_,_,_, buildProgress = Spring.GetUnitHealth(unitID) if losState and ((not udefID) or (buildProgress == 1)) then ghostSites[unitID] = nil end end scanForRemovalUnits = {} end --Commons local function ResetGl() gl.Color(1.0, 1.0, 1.0, 1.0) gl.Texture(false) end local function CheckSpecState() local playerID = Spring.GetMyPlayerID() local _, _, spec = Spring.GetPlayerInfo(playerID) if spec then Spring.Echo("<Ghost Site> Spectator mode. Widget removed.") widgetHandler:RemoveWidget() return false end return true end function widget:Update(dt) updateTimer = updateTimer + dt if (updateTimer < updateInt) then return end updateTimer = 0 if not CheckSpecState() then return false end ScanFeatures() DeleteGhostSites() DeleteGhostFeatures() end function widget:DrawWorld() if devCompat and not shaderObj then InitShader() end DrawGhostSites() DrawGhostFeatures() ResetGl() end function widget:DrawWorldRefraction() DrawGhostSites() DrawGhostFeatures() ResetGl() end function widget:UnitEnteredLos(unitID, unitTeam) if Spring.IsUnitAllied(unitID) then return end local _,_,_,_,buildProgress = Spring.GetUnitHealth(unitID) local udid = Spring.GetUnitDefID(unitID) local udef = UnitDefs[udid] if (udef.isBuilding == true or udef.isFactory == true or udef.speed == 0) and buildProgress ~= 1 then local x, _, z = Spring.GetUnitPosition(unitID) local facing = Spring.GetUnitBuildFacing(unitID) local y = Spring.GetGroundHeight(x,z) -- every single model is offset by 16, pretty retarded if you ask me. ghostSites[unitID] = {x, y, z, udid, unitTeam, "%"..udid..":0", udef.radius + 100, facing * 90} end end
gpl-2.0
lin-zhang/collision_avoidance
app_scripts/serial_PS2X_youbot_twist_uno.lua
2
15177
#!/usr/bin/env luajit local ffi = require("ffi") local ubx = require "ubx" local ts = tostring time=require("time") ubx_utils = require("ubx_utils") require"strict" ni=ubx.node_create("testnode") ubx.load_module(ni, "std_types/stdtypes/stdtypes.so") ubx.load_module(ni, "std_types/testtypes/testtypes.so") ubx.load_module(ni, "std_types/kdl/kdl_types.so") ubx.load_module(ni, "arduino_blocks/arduino_upload/arduino_upload.so") ubx.load_module(ni, "std_blocks/lfds_buffers/lfds_cyclic.so") ubx.load_module(ni, "std_blocks/webif/webif.so") ubx.load_module(ni, "std_blocks/logging/file_logger.so") ubx.load_module(ni, "std_blocks/ptrig/ptrig.so") ubx.load_module(ni, "arduino_blocks/serial_read/serial_read.so") ubx.load_module(ni, "arduino_blocks/ps2x_youbot/ps2x_youbot.so") ubx.load_module(ni, "std_blocks/youbot_driver/youbot_driver.so") ubx.ffi_load_types(ni) print("creating instance of 'webif/webif'") webif1=ubx.block_create(ni, "webif/webif", "webif1", { port="8888" }) print("creating instance of 'youbot/youbot_driver'") youbot1=ubx.block_create(ni, "youbot/youbot_driver", "youbot1", {ethernet_if="eth0" }) print("creating instance of 'arduino_upload/arduino_upload'") arduino_upload1=ubx.block_create(ni, "arduino_upload/arduino_upload", "arduino_upload1", {arduino_upload_config={avrTool='avrdude', micro_controller_model='atmega328p', configFilePath='/usr/share/arduino/hardware/tools/avr/../avrdude.conf', brate=115200, portName='/dev/ttyACM0', hexFile='arduino_blocks/ard_PS2X/build-uno/ard_PS2X.hex'}}) print("creating instance of 'lfds_buffers/cyclic'") fifo1=ubx.block_create(ni, "lfds_buffers/cyclic", "fifo1", {element_num=4,element_size=4}) print("creating instance of 'lfds_buffers/cyclic'") fifo2=ubx.block_create(ni, "lfds_buffers/cyclic", "fifo2", {element_num=4, element_size=128}) print("creating instance of 'lfds_buffers/cyclic'") fifo3=ubx.block_create(ni, "lfds_buffers/cyclic", "fifo3", {element_num=4, element_size=48}) print("creating instance of 'logging/file_logger'") print("creating instance of 'serial_read/serial_read'") serial_read1=ubx.block_create(ni, "serial_read/serial_read", "serial_read1", {serial_read_config={portName='/dev/ttyACM0', brate=38400}}) print("creating instance of 'ps2x_youbot/ps2x_youbot'"); ps2x_youbot1=ubx.block_create(ni, "ps2x_youbot/ps2x_youbot", "ps2x_youbot1", {ps2x_youbot_config={delim=','}}) logger_conf=[[ { -- { blockname='arduino_upload1', portname="rnd", buff_len=1, }, -- { blockname='fifo1', portname="overruns", buff_len=1, }, -- { blockname='ptrig1', portname="tstats", buff_len=3, }, { blockname='ps2x_youbot1', portname="data_out", buff_len=3,data_type="int"}, { blockname='ps2x_youbot1', portname="nData", buff_len=3,data_type="unsigned int"}, } ]] file_log1=ubx.block_create(ni, "logging/file_logger", "file_log1", {filename='report.dat', separator=',', timestamp=1, report_conf=logger_conf}) print("creating instance of 'std_triggers/ptrig'") ptrig1=ubx.block_create(ni, "std_triggers/ptrig", "ptrig1", { period = {sec=0, usec=1000000 }, sched_policy="SCHED_OTHER", sched_priority=0, trig_blocks={ { b=arduino_upload1, num_steps=1, measure=0 }, -- { b=serial_read1, num_steps=1, measure=0 }, -- { b=ps2x_youbot1, num_steps=1, measure=0 }, -- { b=file_log1, num_steps=1, measure=0 } } } ) print("creating instance of 'std_triggers/ptrig'") ptrig2=ubx.block_create(ni, "std_triggers/ptrig", "ptrig2", { period={sec=0, usec=5000 }, sched_policy="SCHED_FIFO", sched_priority=80, trig_blocks={ { b=youbot1, num_steps=1, measure=0 } } } ) print("creating instance of 'std_triggers/ptrig'") ptrig3=ubx.block_create(ni, "std_triggers/ptrig", "ptrig3", { period={sec=0, usec=10000 }, sched_policy="SCHED_FIFO", sched_priority=80, trig_blocks={ { b=serial_read1, num_steps=1, measure=0 }, { b=ps2x_youbot1, num_steps=1, measure=0 } } } ) --- Create a table of all inversely connected ports: local yb_pinv={} ubx.ports_map(youbot1, function(p) local pname = ubx.safe_tostr(p.name) yb_pinv[pname] = ubx.port_clone_conn(youbot1, pname) end) __time=ffi.new("struct ubx_timespec") function gettime() ubx.clock_mono_gettime(__time) return {sec=tonumber(__time.sec), nsec=tonumber(__time.nsec)} end cm_data=ubx.data_alloc(ni, "int32_t") --- Configure the base control mode. -- @param mode control mode. -- @return true if mode was set, false otherwise. function base_set_control_mode(mode) ubx.data_set(cm_data, mode) ubx.port_write(yb_pinv.base_control_mode, cm_data) local res = ubx.port_read_timed(yb_pinv.base_control_mode, cm_data, 3) return ubx.data_tolua(cm_data)==mode end grip_data=ubx.data_alloc(ni, "int32_t") function gripper(v) ubx.data_set(grip_data, v) ubx.port_write(yb_pinv.arm1_gripper, grip_data) end --- Configure the arm control mode. -- @param mode control mode. -- @return true if mode was set, false otherwise. function arm_set_control_mode(mode) ubx.data_set(cm_data, mode) ubx.port_write(yb_pinv.arm1_control_mode, cm_data) local res = ubx.port_read_timed(yb_pinv.arm1_control_mode, cm_data, 3) return ubx.data_tolua(cm_data)==mode end --- Return once the youbot is initialized or raise an error. function base_initialized() local res=ubx.port_read_timed(yb_pinv.base_control_mode, cm_data, 5) return ubx.data_tolua(cm_data)==0 -- 0=MOTORSTOP end --- Return once the youbot is initialized or raise an error. function arm_initialized() local res=ubx.port_read_timed(yb_pinv.arm1_control_mode, cm_data, 5) return ubx.data_tolua(cm_data)==0 -- 0=MOTORSTOP end calib_int=ubx.data_alloc(ni, "int32_t") function arm_calibrate() ubx.port_write(yb_pinv.arm1_calibrate_cmd, calib_int) end base_twist_data=ubx.data_alloc(ni, "struct kdl_twist") base_null_twist_data=ubx.data_alloc(ni, "struct kdl_twist") --- Move with a given twist. -- @param twist table. -- @param dur duration in seconds function base_move_twist(twist_tab, dur) base_set_control_mode(2) -- VELOCITY ubx.data_set(base_twist_data, twist_tab) local ts_start=ffi.new("struct ubx_timespec") local ts_cur=ffi.new("struct ubx_timespec") ubx.clock_mono_gettime(ts_start) ubx.clock_mono_gettime(ts_cur) while ts_cur.sec - ts_start.sec < dur do ubx.port_write(yb_pinv.base_cmd_twist, base_twist_data) ubx.clock_mono_gettime(ts_cur) end ubx.port_write(yb_pinv.base_cmd_twist, base_null_twist_data) end base_vel_data=ubx.data_alloc(ni, "int32_t", 4) base_null_vel_data=ubx.data_alloc(ni, "int32_t", 4) --- Move each wheel with an individual RPM value. -- @param table of size for with wheel velocity -- @param dur time in seconds to apply velocity function base_move_vel(vel_tab, dur) base_set_control_mode(2) -- VELOCITY ubx.data_set(base_vel_data, vel_tab) local dur = {sec=dur, nsec=0} local ts_start=gettime() local ts_cur=gettime() local diff = {sec=0,nsec=0} while true do diff.sec,diff.nsec=time.sub(ts_cur, ts_start) if time.cmp(diff, dur)==1 then break end ubx.port_write(yb_pinv.base_cmd_vel, base_vel_data) ts_cur=gettime() end ubx.port_write(yb_pinv.base_cmd_vel, base_null_vel_data) end base_cur_data=ubx.data_alloc(ni, "int32_t", 4) base_null_cur_data=ubx.data_alloc(ni, "int32_t", 4) --- Move each wheel with an individual current value. -- @param table of size 4 for with wheel current -- @param dur time in seconds to apply currents. function base_move_cur(cur_tab, dur) base_set_control_mode(6) -- CURRENT ubx.data_set(base_cur_data, cur_tab) local ts_start=ffi.new("struct ubx_timespec") local ts_cur=ffi.new("struct ubx_timespec") ubx.clock_mono_gettime(ts_start) ubx.clock_mono_gettime(ts_cur) while ts_cur.sec - ts_start.sec < dur do ubx.port_write(yb_pinv.base_cmd_cur, base_cur_data) ubx.clock_mono_gettime(ts_cur) end ubx.port_write(yb_pinv.base_cmd_cur, base_null_cur_data) end arm_vel_data=ubx.data_alloc(ni, "double", 5) arm_null_vel_data=ubx.data_alloc(ni, "double", 5) --- Move each joint with an individual rad/s value. -- @param table of size for with wheel velocity -- @param dur time in seconds to apply velocity function arm_move_vel(vel_tab, dur) arm_set_control_mode(2) -- VELOCITY ubx.data_set(arm_vel_data, vel_tab) local dur = {sec=dur, nsec=0} local ts_start=gettime() local ts_cur=gettime() local diff = {sec=0,nsec=0} while true do diff.sec,diff.nsec=time.sub(ts_cur, ts_start) if time.cmp(diff, dur)==1 then break end ubx.port_write(yb_pinv.arm1_cmd_vel, arm_vel_data) ts_cur=gettime() end ubx.port_write(yb_pinv.arm1_cmd_vel, arm_null_vel_data) end arm_eff_data=ubx.data_alloc(ni, "double", 5) arm_null_eff_data=ubx.data_alloc(ni, "double", 5) --- Move each wheel with an individual RPM value. -- @param table of size for with wheel effocity -- @param dur time in seconds to apply effocity function arm_move_eff(eff_tab, dur) arm_set_control_mode(6) -- ubx.data_set(arm_eff_data, eff_tab) local dur = {sec=dur, nsec=0} local ts_start=gettime() local ts_eff=gettime() local diff = {sec=0,nsec=0} while true do diff.sec,diff.nsec=time.sub(ts_eff, ts_start) if time.cmp(diff, dur)==1 then break end ubx.port_write(yb_pinv.arm1_cmd_eff, arm_eff_data) ts_eff=gettime() end ubx.port_write(yb_pinv.arm1_cmd_eff, arm_null_eff_data) end arm_cur_data=ubx.data_alloc(ni, "int32_t", 5) arm_null_cur_data=ubx.data_alloc(ni, "int32_t", 5) --- Move each wheel with an individual RPM value. -- @param table of size for with wheel curocity -- @param dur time in seconds to apply curocity function arm_move_cur(cur_tab, dur) arm_set_control_mode(6) -- ubx.data_set(arm_cur_data, cur_tab) local dur = {sec=dur, nsec=0} local ts_start=gettime() local ts_cur=gettime() local diff = {sec=0,nsec=0} while true do diff.sec,diff.nsec=time.sub(ts_cur, ts_start) if time.cmp(diff, dur)==1 then break end ubx.port_write(yb_pinv.arm1_cmd_cur, arm_cur_data) ts_cur=gettime() end ubx.port_write(yb_pinv.arm1_cmd_cur, arm_null_cur_data) end arm_pos_data=ubx.data_alloc(ni, "double", 5) -- arm_null_pos_data=ubx.data_alloc(ni, "double", 5) --- Move each wheel with an individual RPM value. -- @param table of size for with wheel posocity -- @param dur time in seconds to apply posocity function arm_move_pos(pos_tab) arm_set_control_mode(1) -- POS ubx.data_set(arm_pos_data, pos_tab) ubx.port_write(yb_pinv.arm1_cmd_pos, arm_pos_data) end function arm_tuck() arm_move_pos{2.588, 1.022, 2.248, 1.580, 2.591 } end function arm_home() arm_move_pos{0,0,0,0,0} end function help() local help_msg= [[ youbot test script. Base: base_set_control_mode(mode) mode: mstop=0, pos=1, vel=2, cur=6 base_move_twist(twist_tab, dur) move with twist (as Lua table) for dur seconds base_move_vel(vel_tab, dur) move each wheel with individual vel [rpm] for dur seconds base_move_cur(cur_tab, dur) move each wheel with individual current [mA] for dur seconds ]] if nr_arms>=1 then help_msg=help_msg..[[ Arm: run arm_calibrate() (after each power-down) _BEFORE_ using the other arm functions!! arm_calibrate() calibrate the arm. !!! DO THIS FIRST !!! arm_set_control_mode(mode) see base. arm_move_pos(pos_tab, dur) move to pos. pos_tab is Lua table of len=5 [rad] arm_move_vel(vel_tab, dur) move joints. vel_tab is Lua table of len=5 [rad/s] arm_move_eff(eff_tab, dur) move joints. eff_tab is Lua table of len=5 [Nm] arm_move_cur(cur_tab, dur) move joints. cur_tab is Lua table of len=5 [mA] arm_tuck() move arm to "tuck" position arm_home() move arm to "candle" position ]] end if nr_arms>=2 then help_msg=help_msg..[[ WARNING: this script does currently not support the second youbot arm! ]] end print(help_msg) end function fmpc_run(dur_in) base_set_control_mode(2) -- VELOCITY --ubx.block_stop(ptrig1); --ubx.data_set(twist_data, fifo_out_youbot_msr_twist_to_fmpc) local dur = {sec=0, nsec=0} dur.sec,dur.nsec=math.modf(dur_in) dur.nsec = dur.nsec * 1000000000 print(dur.sec, dur.nsec) local ts_start=gettime() local ts_cur=gettime() local diff = {sec=0,nsec=0} --ubx.block_start(ptrig2) while true do ubx.cblock_step(file_rep1) diff.sec,diff.nsec=time.sub(ts_cur, ts_start) if time.cmp(diff, dur)==1 then break end --ubx.port_write(p_cmd_twist, cmd_twist) --assert(ubx.cblock_step(fmpc1)==0); ts_cur=gettime() end --ubx.block_stop(ptrig2) ubx.port_write(p_cmd_twist, null_twist_data) end -- ubx.ni_stat(ni) print("running webif init", ubx.block_init(webif1)) print("running ptrig1 init", ubx.block_init(ptrig1)) print("running ptrig2 init", ubx.block_init(ptrig2)) print("running ptrig3 init", ubx.block_init(ptrig3)) print("running arduino_upload1 init", ubx.block_init(arduino_upload1)) print("running fifo1 init", ubx.block_init(fifo1)) print("running fifo2 init", ubx.block_init(fifo2)) print("running fifo3 init", ubx.block_init(fifo3)) print("running file_log1 init", ubx.block_init(file_log1)) print("running serial_read1 init", ubx.block_init(serial_read1)) print("running ps2x_youbot1 init", ubx.block_init(ps2x_youbot1)) print("running youbot1 init",ubx.block_init(youbot1)) nr_arms=ubx.data_tolua(ubx.config_get_data(youbot1, "nr_arms")) print("running webif start", ubx.block_start(webif1)) rand_port=ubx.port_get(arduino_upload1, "rnd") ubx.port_connect_out(rand_port, fifo1) serial_read_out_port=ubx.port_get(serial_read1, "string_read") ps2x_youbot_in_port=ubx.port_get(ps2x_youbot1, "string_in"); ubx.port_connect_out(serial_read_out_port, fifo2); ubx.port_connect_in(ps2x_youbot_in_port, fifo2); youbot_cmd_vel_port=ubx.port_get(youbot1, "base_cmd_twist"); ps2x_youbot_cmd_vel_port=ubx.port_get(ps2x_youbot1, "base_cmd_twist"); ubx.port_connect_out(ps2x_youbot_cmd_vel_port, fifo3); ubx.port_connect_in(youbot_cmd_vel_port, fifo3); ubx.block_start(ptrig1) ubx.block_start(file_log1) ubx.block_start(fifo1) ubx.block_start(fifo2) ubx.block_start(fifo3) ubx.block_start(arduino_upload1) ubx.block_start(serial_read1) ubx.block_start(ps2x_youbot1) ubx.block_start(youbot1) ubx.block_start(ptrig2) ubx.block_start(ptrig3) base_initialized() if nr_arms==1 then arm_initialized() elseif nr_arms==2 then print("WARNING: this script does not yet support a two arm youbot (the driver does however)") end twst={vel={x=0.05,y=0,z=0},rot={x=0,y=0,z=0.1}} vel_tab={1,1,1,1} arm_vel_tab={0.002,0.002,0.003,0.002, 0.002} print('Please run "help()" for information on available functions') --print(utils.tab2str(ubx.block_totab(arduino_upload1))) --print("--- demo app launched, browse to http://localhost:8888 and start ptrig1 block to start up") --io.read() --ubx.node_cleanup(ni) --os.exit(1)
gpl-2.0
szaszg/lxc
src/lua-lxc/lxc.lua
26
10159
-- -- lua lxc module -- -- Copyright © 2012 Oracle. -- -- Authors: -- Dwight Engen <dwight.engen@oracle.com> -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this library; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -- local core = require("lxc.core") local lfs = require("lfs") local table = require("table") local string = require("string") local io = require("io") module("lxc", package.seeall) local lxc_path local log_level = 3 -- lua 5.1 compat if table.unpack == nil then table.unpack = unpack end -- the following two functions can be useful for debugging function printf(...) local function wrapper(...) io.write(string.format(...)) end local status, result = pcall(wrapper, ...) if not status then error(result, 2) end end function log(level, ...) if (log_level >= level) then printf(os.date("%Y-%m-%d %T ")) printf(...) end end function string:split(delim, max_cols) local cols = {} local start = 1 local nextc repeat nextc = string.find(self, delim, start) if (nextc and #cols ~= max_cols - 1) then table.insert(cols, string.sub(self, start, nextc-1)) start = nextc + #delim else table.insert(cols, string.sub(self, start, string.len(self))) nextc = nil end until nextc == nil or start > #self return cols end -- container class container = {} container_mt = {} container_mt.__index = container function container:new(lname, config) local lcore local lnetcfg = {} local lstats = {} if lname then if config then lcore = core.container_new(lname, config) else lcore = core.container_new(lname) end end return setmetatable({ctname = lname, core = lcore, netcfg = lnetcfg, stats = lstats}, container_mt) end -- methods interfacing to core functionality function container:attach(what, ...) return self.core:attach(what, ...) end function container:config_file_name() return self.core:config_file_name() end function container:defined() return self.core:defined() end function container:init_pid() return self.core:init_pid() end function container:name() return self.core:name() end function container:start() return self.core:start() end function container:stop() return self.core:stop() end function container:shutdown(timeout) return self.core:shutdown(timeout) end function container:wait(state, timeout) return self.core:wait(state, timeout) end function container:freeze() return self.core:freeze() end function container:unfreeze() return self.core:unfreeze() end function container:running() return self.core:running() end function container:state() return self.core:state() end function container:create(template, ...) return self.core:create(template, ...) end function container:destroy() return self.core:destroy() end function container:get_config_path() return self.core:get_config_path() end function container:set_config_path(path) return self.core:set_config_path(path) end function container:append_config_item(key, value) return self.core:set_config_item(key, value) end function container:clear_config_item(key) return self.core:clear_config_item(key) end function container:get_cgroup_item(key) return self.core:get_cgroup_item(key) end function container:get_config_item(key) local value local vals = {} value = self.core:get_config_item(key) -- check if it is a single item if (not value or not string.find(value, "\n")) then return value end -- it must be a list type item, make a table of it vals = value:split("\n", 1000) -- make it a "mixed" table, ie both dictionary and list for ease of use for _,v in ipairs(vals) do vals[v] = true end return vals end function container:set_cgroup_item(key, value) return self.core:set_cgroup_item(key, value) end function container:set_config_item(key, value) return self.core:set_config_item(key, value) end function container:get_keys(base) local ktab = {} local keys if (base) then keys = self.core:get_keys(base) base = base .. "." else keys = self.core:get_keys() base = "" end if (keys == nil) then return nil end keys = keys:split("\n", 1000) for _,v in ipairs(keys) do local config_item = base .. v ktab[v] = self.core:get_config_item(config_item) end return ktab end function container:load_config(alt_path) if (alt_path) then return self.core:load_config(alt_path) else return self.core:load_config() end end function container:save_config(alt_path) if (alt_path) then return self.core:save_config(alt_path) else return self.core:save_config() end end -- methods for stats collection from various cgroup files -- read integers at given coordinates from a cgroup file function container:stat_get_ints(item, coords) local lines = {} local result = {} local flines = self:get_cgroup_item(item) if (flines == nil) then for k,c in ipairs(coords) do table.insert(result, 0) end else for line in flines:gmatch("[^\r\n]+") do table.insert(lines, line) end for k,c in ipairs(coords) do local col col = lines[c[1]]:split(" ", 80) local val = tonumber(col[c[2]]) table.insert(result, val) end end return table.unpack(result) end -- read an integer from a cgroup file function container:stat_get_int(item) local line = self:get_cgroup_item(item) -- if line is nil (on an error like Operation not supported because -- CONFIG_MEMCG_SWAP_ENABLED isn't enabled) return 0 return tonumber(line) or 0 end function container:stat_match_get_int(item, match, column) local val local lines = self:get_cgroup_item(item) if (lines == nil) then return 0 end for line in lines:gmatch("[^\r\n]+") do if (string.find(line, match)) then local col col = line:split(" ", 80) val = tonumber(col[column]) or 0 end end return val end function container:stats_get(total) local stat = {} stat.mem_used = self:stat_get_int("memory.usage_in_bytes") stat.mem_limit = self:stat_get_int("memory.limit_in_bytes") stat.memsw_used = self:stat_get_int("memory.memsw.usage_in_bytes") stat.memsw_limit = self:stat_get_int("memory.memsw.limit_in_bytes") stat.kmem_used = self:stat_get_int("memory.kmem.usage_in_bytes") stat.kmem_limit = self:stat_get_int("memory.kmem.limit_in_bytes") stat.cpu_use_nanos = self:stat_get_int("cpuacct.usage") stat.cpu_use_user, stat.cpu_use_sys = self:stat_get_ints("cpuacct.stat", {{1, 2}, {2, 2}}) stat.blkio = self:stat_match_get_int("blkio.throttle.io_service_bytes", "Total", 2) if (total) then total.mem_used = total.mem_used + stat.mem_used total.mem_limit = total.mem_limit + stat.mem_limit total.memsw_used = total.memsw_used + stat.memsw_used total.memsw_limit = total.memsw_limit + stat.memsw_limit total.kmem_used = total.kmem_used + stat.kmem_used total.kmem_limit = total.kmem_limit + stat.kmem_limit total.cpu_use_nanos = total.cpu_use_nanos + stat.cpu_use_nanos total.cpu_use_user = total.cpu_use_user + stat.cpu_use_user total.cpu_use_sys = total.cpu_use_sys + stat.cpu_use_sys total.blkio = total.blkio + stat.blkio end return stat end local M = { container = container } function M.stats_clear(stat) stat.mem_used = 0 stat.mem_limit = 0 stat.memsw_used = 0 stat.memsw_limit = 0 stat.kmem_used = 0 stat.kmem_limit = 0 stat.cpu_use_nanos = 0 stat.cpu_use_user = 0 stat.cpu_use_sys = 0 stat.blkio = 0 end -- return configured containers found in LXC_PATH directory function M.containers_configured(names_only) local containers = {} for dir in lfs.dir(lxc_path) do if (dir ~= "." and dir ~= "..") then local cfgfile = lxc_path .. "/" .. dir .. "/config" local cfgattr = lfs.attributes(cfgfile) if (cfgattr and cfgattr.mode == "file") then if (names_only) then -- note, this is a "mixed" table, ie both dictionary and list containers[dir] = true table.insert(containers, dir) else local ct = container:new(dir) -- note, this is a "mixed" table, ie both dictionary and list containers[dir] = ct table.insert(containers, dir) end end end end table.sort(containers, function (a,b) return (a < b) end) return containers end -- return running containers found in cgroup fs function M.containers_running(names_only) local containers = {} local names = M.containers_configured(true) for _,name in ipairs(names) do local ct = container:new(name) if ct:running() then -- note, this is a "mixed" table, ie both dictionary and list table.insert(containers, name) if (names_only) then containers[name] = true ct = nil else containers[name] = ct end end end table.sort(containers, function (a,b) return (a < b) end) return containers end function M.version_get() return core.version_get() end function M.default_config_path_get() return core.default_config_path_get() end function M.cmd_get_config_item(name, item, lxcpath) if (lxcpath) then return core.cmd_get_config_item(name, item, lxcpath) else return core.cmd_get_config_item(name, item) end end lxc_path = core.default_config_path_get() return M
lgpl-2.1
gajop/Zero-K
effects/gundam_artillery_explosion.lua
25
3488
-- artillery_explosion return { ["artillery_explosion"] = { dirt = { count = 4, ground = true, properties = { alphafalloff = 2, alwaysvisible = true, color = [[0.2, 0.1, 0.05]], pos = [[r-25 r25, 0, r-25 r25]], size = 30, speed = [[r1.5 r-1.5, 2, r1.5 r-1.5]], }, }, groundflash = { air = true, alwaysvisible = true, circlealpha = 0.6, circlegrowth = 9, flashalpha = 0.9, flashsize = 150, ground = true, ttl = 13, water = true, color = { [1] = 1, [2] = 0.20000000298023, [3] = 0.10000000149012, }, }, poof01 = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, properties = { airdrag = 0.8, alwaysvisible = true, colormap = [[1.0 1.0 1.0 0.04 0.9 0.2 0.2 0.01 0.8 0.1 0.0 0.01]], directional = true, emitrot = 45, emitrotspread = 32, emitvector = [[0, 1, 0]], gravity = [[0, -0.05, 0]], numparticles = 8, particlelife = 10, particlelifespread = 0, particlesize = 30, particlesizespread = 0, particlespeed = 5, particlespeedspread = 5, pos = [[0, 2, 0]], sizegrowth = 1, sizemod = 1.0, texture = [[flashside1]], useairlos = false, }, }, pop1 = { air = true, class = [[heatcloud]], count = 2, ground = true, water = true, properties = { alwaysvisible = true, heat = 10, heatfalloff = 1.1, maxheat = 15, pos = [[r-2 r2, 5, r-2 r2]], size = 1, sizegrowth = 16, speed = [[0, 1 0, 0]], texture = [[crimsonnovaexplo]], }, }, smoke = { air = true, count = 4, ground = true, water = true, properties = { agespeed = 0.01, alwaysvisible = true, color = 0.1, pos = [[r-20 r20, 34, r-20 r20]], size = 50, sizeexpansion = 0.6, sizegrowth = 15, speed = [[r-2 r2, 1 r2.3, r-2 r2]], startsize = 10, }, }, whiteglow = { air = true, class = [[heatcloud]], count = 2, ground = true, water = true, properties = { alwaysvisible = true, heat = 10, heatfalloff = 3.5, maxheat = 15, pos = [[0, 0, 0]], size = 5, sizegrowth = 40, speed = [[0, 0, 0]], texture = [[laserend]], }, }, }, }
gpl-2.0
jayman39tx/naev
dat/scripts/jumpdist.lua
16
2247
--[[ -- @brief Fetches an array of systems from min to max jumps away from the given -- system sys. -- -- The following example gets a random Sirius M class planet between 1 to 6 jumps away. -- -- @code -- local planets = {} -- getsysatdistance( system.cur(), 1, 6, -- function(s) -- for i, v in ipairs(s:planets()) do -- if v:faction() == faction.get("Sirius") and v:class() == "M" then -- return true -- end -- end -- return false -- end ) -- -- if #planets == 0 then abort() end -- Sanity in case no suitable planets are in range. -- -- local index = rnd.rnd(1, #planets) -- destplanet = planets[index][1] -- destsys = planets[index][2] -- @endcode -- -- @param sys System to calculate distance from or nil to use current system -- @param min Min distance to check for. -- @param max Maximum distance to check for. -- @param filter Optional filter function to use for more details. -- @param data Data to pass to filter -- @param hidden Whether or not to consider hidden jumps (off by default) -- @return The table of systems n jumps away from sys --]] function getsysatdistance( sys, min, max, filter, data, hidden ) -- Get default parameters if sys == nil then sys = system.cur() end if max == nil then max = min end open = { sys } close = { [sys:name()]=sys } dist = { [sys:name()]=0 } -- Run max times for i=1,max do nopen = {} -- Get all the adjacent system of the current set for _,s in ipairs(open) do adjsys = s:adjacentSystems( hidden ) -- Get them all for _,a in ipairs(adjsys) do -- Must not have been explored previously if close[ a:name() ] == nil then nopen[ #nopen+1 ] = a close[ a:name() ] = a dist[ a:name() ] = i end end end open = nopen -- New table becomes the old end -- Now we filter the solutions finalset = {} for i,s in pairs(close) do if dist[i] >= min and dist[i] <= max and (filter == nil or filter(s,data)) then finalset[ #finalset+1 ] = s end end return finalset end
gpl-3.0
wangtianhang/UnityLuaTest
toluaSnapshotTest/toluaRuntime/luajit-2.1/src/host/genminilua.lua
47
12039
---------------------------------------------------------------------------- -- Lua script to generate a customized, minified version of Lua. -- The resulting 'minilua' is used for the build process of LuaJIT. ---------------------------------------------------------------------------- -- Copyright (C) 2005-2017 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- local sub, match, gsub = string.sub, string.match, string.gsub local LUA_VERSION = "5.1.5" local LUA_SOURCE local function usage() io.stderr:write("Usage: ", arg and arg[0] or "genminilua", " lua-", LUA_VERSION, "-source-dir\n") os.exit(1) end local function find_sources() LUA_SOURCE = arg and arg[1] if not LUA_SOURCE then usage() end if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end local fp = io.open(LUA_SOURCE .. "lua.h") if not fp then LUA_SOURCE = LUA_SOURCE.."src/" fp = io.open(LUA_SOURCE .. "lua.h") if not fp then usage() end end local all = fp:read("*a") fp:close() if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then io.stderr:write("Error: version mismatch\n") usage() end end local LUA_FILES = { "lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c", "lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c", "llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c", "lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c", } local REMOVE_LIB = {} gsub([[ collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset select tostring xpcall foreach foreachi getn maxn setn popen tmpfile seek setvbuf __tostring clock date difftime execute getenv rename setlocale time tmpname dump gfind len reverse LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME ]], "%S+", function(name) REMOVE_LIB[name] = true end) local REMOVE_EXTINC = { ["<assert.h>"] = true, ["<locale.h>"] = true, } local CUSTOM_MAIN = [[ typedef unsigned int UB; static UB barg(lua_State *L,int idx){ union{lua_Number n;U64 b;}bn; bn.n=lua_tonumber(L,idx)+6755399441055744.0; if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); return(UB)bn.b; } #define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1; static int tobit(lua_State *L){ BRET(barg(L,1))} static int bnot(lua_State *L){ BRET(~barg(L,1))} static int band(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} static int bor(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} static int bxor(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} static int lshift(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET(b<<n)} static int rshift(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET(b>>n)} static int arshift(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} static int rol(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b<<n)|(b>>(32-n)))} static int ror(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} static int bswap(lua_State *L){ UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} static int tohex(lua_State *L){ UB b=barg(L,1); int n=lua_isnone(L,2)?8:(int)barg(L,2); const char *hexdigits="0123456789abcdef"; char buf[8]; int i; if(n<0){n=-n;hexdigits="0123456789ABCDEF";} if(n>8)n=8; for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} lua_pushlstring(L,buf,(size_t)n); return 1; } static const struct luaL_Reg bitlib[] = { {"tobit",tobit}, {"bnot",bnot}, {"band",band}, {"bor",bor}, {"bxor",bxor}, {"lshift",lshift}, {"rshift",rshift}, {"arshift",arshift}, {"rol",rol}, {"ror",ror}, {"bswap",bswap}, {"tohex",tohex}, {NULL,NULL} }; int main(int argc, char **argv){ lua_State *L = luaL_newstate(); int i; luaL_openlibs(L); luaL_register(L, "bit", bitlib); if (argc < 2) return sizeof(void *); lua_createtable(L, 0, 1); lua_pushstring(L, argv[1]); lua_rawseti(L, -2, 0); lua_setglobal(L, "arg"); if (luaL_loadfile(L, argv[1])) goto err; for (i = 2; i < argc; i++) lua_pushstring(L, argv[i]); if (lua_pcall(L, argc - 2, 0, 0)) { err: fprintf(stderr, "Error: %s\n", lua_tostring(L, -1)); return 1; } lua_close(L); return 0; } ]] local function read_sources() local t = {} for i, name in ipairs(LUA_FILES) do local fp = assert(io.open(LUA_SOURCE..name, "r")) t[i] = fp:read("*a") assert(fp:close()) end t[#t+1] = CUSTOM_MAIN return table.concat(t) end local includes = {} local function merge_includes(src) return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name) if includes[name] then return "" end includes[name] = true local fp = assert(io.open(LUA_SOURCE..name, "r")) local inc = fp:read("*a") assert(fp:close()) inc = gsub(inc, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "") inc = gsub(inc, "#endif%s*$", "") return merge_includes(inc) end) end local function get_license(src) return match(src, "/%*+\n%* Copyright %(.-%*/\n") end local function fold_lines(src) return gsub(src, "\\\n", " ") end local strings = {} local function save_str(str) local n = #strings+1 strings[n] = str return "\1"..n.."\2" end local function save_strings(src) src = gsub(src, '"[^"\n]*"', save_str) return gsub(src, "'[^'\n]*'", save_str) end local function restore_strings(src) return gsub(src, "\1(%d+)\2", function(numstr) return strings[tonumber(numstr)] end) end local function def_istrue(def) return def == "INT_MAX > 2147483640L" or def == "LUAI_BITSINT >= 32" or def == "SIZE_Bx < LUAI_BITSINT-1" or def == "cast" or def == "defined(LUA_CORE)" or def == "MINSTRTABSIZE" or def == "LUA_MINBUFFER" or def == "HARDSTACKTESTS" or def == "UNUSED" end local head, defs = {[[ #ifdef _MSC_VER typedef unsigned __int64 U64; #else typedef unsigned long long U64; #endif int _CRT_glob = 0; ]]}, {} local function preprocess(src) local t = { match(src, "^(.-)#") } local lvl, on, oldon = 0, true, {} for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do if pp == "if" or pp == "ifdef" or pp == "ifndef" then lvl = lvl + 1 oldon[lvl] = on on = def_istrue(def) elseif pp == "else" then if oldon[lvl] then if on == false then on = true else on = false end end elseif pp == "elif" then if oldon[lvl] then on = def_istrue(def) end elseif pp == "endif" then on = oldon[lvl] lvl = lvl - 1 elseif on then if pp == "include" then if not head[def] and not REMOVE_EXTINC[def] then head[def] = true head[#head+1] = "#include "..def.."\n" end elseif pp == "define" then local k, sp, v = match(def, "([%w_]+)(%s*)(.*)") if k and not (sp == "" and sub(v, 1, 1) == "(") then defs[k] = gsub(v, "%a[%w_]*", function(tok) return defs[tok] or tok end) else t[#t+1] = "#define "..def.."\n" end elseif pp ~= "undef" then error("unexpected directive: "..pp.." "..def) end end if on then t[#t+1] = txt end end return gsub(table.concat(t), "%a[%w_]*", function(tok) return defs[tok] or tok end) end local function merge_header(src, license) local hdr = string.format([[ /* This is a heavily customized and minimized copy of Lua %s. */ /* It's only used to build LuaJIT. It does NOT have all standard functions! */ ]], LUA_VERSION) return hdr..license..table.concat(head)..src end local function strip_unused1(src) return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func) return REMOVE_LIB[func] and "" or line end) end local function strip_unused2(src) return gsub(src, "Symbolic Execution.-}=", "") end local function strip_unused3(src) src = gsub(src, "extern", "static") src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(") src = gsub(src, "#define lua_assert[^\n]*\n", "") src = gsub(src, "lua_assert%b();?", "") src = gsub(src, "default:\n}", "default:;\n}") src = gsub(src, "lua_lock%b();", "") src = gsub(src, "lua_unlock%b();", "") src = gsub(src, "luai_threadyield%b();", "") src = gsub(src, "luai_userstateopen%b();", "{}") src = gsub(src, "luai_userstate%w+%b();", "") src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser") src = gsub(src, "trydecpoint%(ls,seminfo%)", "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") src = gsub(src, "int c=luaZ_lookahead%b();", "") src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", "return 1;") src = gsub(src, "getfuncname%b():", "NULL:") src = gsub(src, "getobjname%b():", "NULL:") src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "") src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "") src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "") src = gsub(src, "(twoto%b()%()", "%1(size_t)") src = gsub(src, "i<sizenode", "i<(int)sizenode") src = gsub(src, "cast%(unsigned int,key%-1%)", "cast(unsigned int,key)-1") return gsub(src, "\n\n+", "\n") end local function strip_comments(src) return gsub(src, "/%*.-%*/", " ") end local function strip_whitespace(src) src = gsub(src, "^%s+", "") src = gsub(src, "%s*\n%s*", "\n") src = gsub(src, "[ \t]+", " ") src = gsub(src, "(%W) ", "%1") return gsub(src, " (%W)", "%1") end local function rename_tokens1(src) src = gsub(src, "getline", "getline_") src = gsub(src, "struct ([%w_]+)", "ZX%1") return gsub(src, "union ([%w_]+)", "ZY%1") end local function rename_tokens2(src) src = gsub(src, "ZX([%w_]+)", "struct %1") return gsub(src, "ZY([%w_]+)", "union %1") end local function func_gather(src) local nodes, list = {}, {} local pos, len = 1, #src while pos < len do local d, w = match(src, "^(#define ([%w_]+)[^\n]*\n)", pos) if d then local n = #list+1 list[n] = d nodes[w] = n else local s d, w, s = match(src, "^(([%w_]+)[^\n]*([{;])\n)", pos) if not d then d, w, s = match(src, "^(([%w_]+)[^(]*%b()([{;])\n)", pos) if not d then d = match(src, "^[^\n]*\n", pos) end end if s == "{" then d = d..sub(match(src, "^%b{}[^;\n]*;?\n", pos+#d-2), 3) if sub(d, -2) == "{\n" then d = d..sub(match(src, "^%b{}[^;\n]*;?\n", pos+#d-2), 3) end end local k, v = nil, d if w == "typedef" then if match(d, "^typedef enum") then head[#head+1] = d else k = match(d, "([%w_]+);\n$") if not k then k = match(d, "^.-%(.-([%w_]+)%)%(") end end elseif w == "enum" then head[#head+1] = v elseif w ~= nil then k = match(d, "^[^\n]-([%w_]+)[(%[=]") if k then if w ~= "static" and k ~= "main" then v = "static "..d end else k = w end end if w and k then local o = nodes[k] if o then nodes["*"..k] = o end local n = #list+1 list[n] = v nodes[k] = n end end pos = pos + #d end return nodes, list end local function func_visit(nodes, list, used, n) local i = nodes[n] for m in string.gmatch(list[i], "[%w_]+") do if nodes[m] then local j = used[m] if not j then used[m] = i func_visit(nodes, list, used, m) elseif i < j then used[m] = i end end end end local function func_collect(src) local nodes, list = func_gather(src) local used = {} func_visit(nodes, list, used, "main") for n,i in pairs(nodes) do local j = used[n] if j and j < i then used["*"..n] = j end end for n,i in pairs(nodes) do if not used[n] then list[i] = "" end end return table.concat(list) end find_sources() local src = read_sources() src = merge_includes(src) local license = get_license(src) src = fold_lines(src) src = strip_unused1(src) src = save_strings(src) src = strip_unused2(src) src = strip_comments(src) src = preprocess(src) src = strip_whitespace(src) src = strip_unused3(src) src = rename_tokens1(src) src = func_collect(src) src = rename_tokens2(src) src = restore_strings(src) src = merge_header(src, license) io.write(src)
mit
nobie/sesame_fw
feeds/luci/contrib/luadoc/lua/luadoc/taglet/standard.lua
93
16319
------------------------------------------------------------------------------- -- @release $Id: standard.lua,v 1.39 2007/12/21 17:50:48 tomas Exp $ ------------------------------------------------------------------------------- local assert, pairs, tostring, type = assert, pairs, tostring, type local io = require "io" local posix = require "nixio.fs" local luadoc = require "luadoc" local util = require "luadoc.util" local tags = require "luadoc.taglet.standard.tags" local string = require "string" local table = require "table" module 'luadoc.taglet.standard' ------------------------------------------------------------------------------- -- Creates an iterator for an array base on a class type. -- @param t array to iterate over -- @param class name of the class to iterate over function class_iterator (t, class) return function () local i = 1 return function () while t[i] and t[i].class ~= class do i = i + 1 end local v = t[i] i = i + 1 return v end end end -- Patterns for function recognition local identifiers_list_pattern = "%s*(.-)%s*" local identifier_pattern = "[^%(%s]+" local function_patterns = { "^()%s*function%s*("..identifier_pattern..")%s*%("..identifiers_list_pattern.."%)", "^%s*(local%s)%s*function%s*("..identifier_pattern..")%s*%("..identifiers_list_pattern.."%)", "^()%s*("..identifier_pattern..")%s*%=%s*function%s*%("..identifiers_list_pattern.."%)", } ------------------------------------------------------------------------------- -- Checks if the line contains a function definition -- @param line string with line text -- @return function information or nil if no function definition found local function check_function (line) line = util.trim(line) local info = table.foreachi(function_patterns, function (_, pattern) local r, _, l, id, param = string.find(line, pattern) if r ~= nil then return { name = id, private = (l == "local"), param = { } --util.split("%s*,%s*", param), } end end) -- TODO: remove these assert's? if info ~= nil then assert(info.name, "function name undefined") assert(info.param, string.format("undefined parameter list for function `%s'", info.name)) end return info end ------------------------------------------------------------------------------- -- Checks if the line contains a module definition. -- @param line string with line text -- @param currentmodule module already found, if any -- @return the name of the defined module, or nil if there is no module -- definition local function check_module (line, currentmodule) line = util.trim(line) -- module"x.y" -- module'x.y' -- module[[x.y]] -- module("x.y") -- module('x.y') -- module([[x.y]]) -- module(...) local r, _, modulename = string.find(line, "^module%s*[%s\"'(%[]+([^,\"')%]]+)") if r then -- found module definition logger:debug(string.format("found module `%s'", modulename)) return modulename end return currentmodule end -- Patterns for constant recognition local constant_patterns = { "^()%s*([A-Z][A-Z0-9_]*)%s*=", "^%s*(local%s)%s*([A-Z][A-Z0-9_]*)%s*=", } ------------------------------------------------------------------------------- -- Checks if the line contains a constant definition -- @param line string with line text -- @return constant information or nil if no constant definition found local function check_constant (line) line = util.trim(line) local info = table.foreachi(constant_patterns, function (_, pattern) local r, _, l, id = string.find(line, pattern) if r ~= nil then return { name = id, private = (l == "local"), } end end) -- TODO: remove these assert's? if info ~= nil then assert(info.name, "constant name undefined") end return info end ------------------------------------------------------------------------------- -- Extracts summary information from a description. The first sentence of each -- doc comment should be a summary sentence, containing a concise but complete -- description of the item. It is important to write crisp and informative -- initial sentences that can stand on their own -- @param description text with item description -- @return summary string or nil if description is nil local function parse_summary (description) -- summary is never nil... description = description or "" -- append an " " at the end to make the pattern work in all cases description = description.." " -- read until the first period followed by a space or tab local summary = string.match(description, "(.-%.)[%s\t]") -- if pattern did not find the first sentence, summary is the whole description summary = summary or description return summary end ------------------------------------------------------------------------------- -- @param f file handle -- @param line current line being parsed -- @param modulename module already found, if any -- @return current line -- @return code block -- @return modulename if found local function parse_code (f, line, modulename) local code = {} while line ~= nil do if string.find(line, "^[\t ]*%-%-%-") then -- reached another luadoc block, end this parsing return line, code, modulename else -- look for a module definition modulename = check_module(line, modulename) table.insert(code, line) line = f:read() end end -- reached end of file return line, code, modulename end ------------------------------------------------------------------------------- -- Parses the information inside a block comment -- @param block block with comment field -- @return block parameter local function parse_comment (block, first_line, modulename) -- get the first non-empty line of code local code = table.foreachi(block.code, function(_, line) if not util.line_empty(line) then -- `local' declarations are ignored in two cases: -- when the `nolocals' option is turned on; and -- when the first block of a file is parsed (this is -- necessary to avoid confusion between the top -- local declarations and the `module' definition. if (options.nolocals or first_line) and line:find"^%s*local" then return end return line end end) -- parse first line of code if code ~= nil then local func_info = check_function(code) local module_name = check_module(code) local const_info = check_constant(code) if func_info then block.class = "function" block.name = func_info.name block.param = func_info.param block.private = func_info.private elseif const_info then block.class = "constant" block.name = const_info.name block.private = const_info.private elseif module_name then block.class = "module" block.name = module_name block.param = {} else block.param = {} end else -- TODO: comment without any code. Does this means we are dealing -- with a file comment? end -- parse @ tags local currenttag = "description" local currenttext table.foreachi(block.comment, function (_, line) line = util.trim_comment(line) local r, _, tag, text = string.find(line, "@([_%w%.]+)%s+(.*)") if r ~= nil then -- found new tag, add previous one, and start a new one -- TODO: what to do with invalid tags? issue an error? or log a warning? tags.handle(currenttag, block, currenttext) currenttag = tag currenttext = text else currenttext = util.concat(currenttext, line) assert(string.sub(currenttext, 1, 1) ~= " ", string.format("`%s', `%s'", currenttext, line)) end end) tags.handle(currenttag, block, currenttext) -- extracts summary information from the description block.summary = parse_summary(block.description) assert(string.sub(block.description, 1, 1) ~= " ", string.format("`%s'", block.description)) if block.name and block.class == "module" then modulename = block.name end return block, modulename end ------------------------------------------------------------------------------- -- Parses a block of comment, started with ---. Read until the next block of -- comment. -- @param f file handle -- @param line being parsed -- @param modulename module already found, if any -- @return line -- @return block parsed -- @return modulename if found local function parse_block (f, line, modulename, first) local block = { comment = {}, code = {}, } while line ~= nil do if string.find(line, "^[\t ]*%-%-") == nil then -- reached end of comment, read the code below it -- TODO: allow empty lines line, block.code, modulename = parse_code(f, line, modulename) -- parse information in block comment block, modulename = parse_comment(block, first, modulename) return line, block, modulename else table.insert(block.comment, line) line = f:read() end end -- reached end of file -- parse information in block comment block, modulename = parse_comment(block, first, modulename) return line, block, modulename end ------------------------------------------------------------------------------- -- Parses a file documented following luadoc format. -- @param filepath full path of file to parse -- @param doc table with documentation -- @return table with documentation function parse_file (filepath, doc, handle, prev_line, prev_block, prev_modname) local blocks = { prev_block } local modulename = prev_modname -- read each line local f = handle or io.open(filepath, "r") local i = 1 local line = prev_line or f:read() local first = true while line ~= nil do if string.find(line, "^[\t ]*%-%-%-") then -- reached a luadoc block local block, newmodname line, block, newmodname = parse_block(f, line, modulename, first) if modulename and newmodname and newmodname ~= modulename then doc = parse_file( nil, doc, f, line, block, newmodname ) else table.insert(blocks, block) modulename = newmodname end else -- look for a module definition local newmodname = check_module(line, modulename) if modulename and newmodname and newmodname ~= modulename then parse_file( nil, doc, f ) else modulename = newmodname end -- TODO: keep beginning of file somewhere line = f:read() end first = false i = i + 1 end if not handle then f:close() end if filepath then -- store blocks in file hierarchy assert(doc.files[filepath] == nil, string.format("doc for file `%s' already defined", filepath)) table.insert(doc.files, filepath) doc.files[filepath] = { type = "file", name = filepath, doc = blocks, -- functions = class_iterator(blocks, "function"), -- tables = class_iterator(blocks, "table"), } -- local first = doc.files[filepath].doc[1] if first and modulename then doc.files[filepath].author = first.author doc.files[filepath].copyright = first.copyright doc.files[filepath].description = first.description doc.files[filepath].release = first.release doc.files[filepath].summary = first.summary end end -- if module definition is found, store in module hierarchy if modulename ~= nil then if modulename == "..." then assert( filepath, "Can't determine name for virtual module from filepatch" ) modulename = string.gsub (filepath, "%.lua$", "") modulename = string.gsub (modulename, "/", ".") end if doc.modules[modulename] ~= nil then -- module is already defined, just add the blocks table.foreachi(blocks, function (_, v) table.insert(doc.modules[modulename].doc, v) end) else -- TODO: put this in a different module table.insert(doc.modules, modulename) doc.modules[modulename] = { type = "module", name = modulename, doc = blocks, -- functions = class_iterator(blocks, "function"), -- tables = class_iterator(blocks, "table"), author = first and first.author, copyright = first and first.copyright, description = "", release = first and first.release, summary = "", } -- find module description for m in class_iterator(blocks, "module")() do doc.modules[modulename].description = util.concat( doc.modules[modulename].description, m.description) doc.modules[modulename].summary = util.concat( doc.modules[modulename].summary, m.summary) if m.author then doc.modules[modulename].author = m.author end if m.copyright then doc.modules[modulename].copyright = m.copyright end if m.release then doc.modules[modulename].release = m.release end if m.name then doc.modules[modulename].name = m.name end end doc.modules[modulename].description = doc.modules[modulename].description or (first and first.description) or "" doc.modules[modulename].summary = doc.modules[modulename].summary or (first and first.summary) or "" end -- make functions table doc.modules[modulename].functions = {} for f in class_iterator(blocks, "function")() do if f and f.name then table.insert(doc.modules[modulename].functions, f.name) doc.modules[modulename].functions[f.name] = f end end -- make tables table doc.modules[modulename].tables = {} for t in class_iterator(blocks, "table")() do if t and t.name then table.insert(doc.modules[modulename].tables, t.name) doc.modules[modulename].tables[t.name] = t end end -- make constants table doc.modules[modulename].constants = {} for c in class_iterator(blocks, "constant")() do if c and c.name then table.insert(doc.modules[modulename].constants, c.name) doc.modules[modulename].constants[c.name] = c end end end if filepath then -- make functions table doc.files[filepath].functions = {} for f in class_iterator(blocks, "function")() do if f and f.name then table.insert(doc.files[filepath].functions, f.name) doc.files[filepath].functions[f.name] = f end end -- make tables table doc.files[filepath].tables = {} for t in class_iterator(blocks, "table")() do if t and t.name then table.insert(doc.files[filepath].tables, t.name) doc.files[filepath].tables[t.name] = t end end end return doc end ------------------------------------------------------------------------------- -- Checks if the file is terminated by ".lua" or ".luadoc" and calls the -- function that does the actual parsing -- @param filepath full path of the file to parse -- @param doc table with documentation -- @return table with documentation -- @see parse_file function file (filepath, doc) local patterns = { "%.lua$", "%.luadoc$" } local valid = table.foreachi(patterns, function (_, pattern) if string.find(filepath, pattern) ~= nil then return true end end) if valid then logger:info(string.format("processing file `%s'", filepath)) doc = parse_file(filepath, doc) end return doc end ------------------------------------------------------------------------------- -- Recursively iterates through a directory, parsing each file -- @param path directory to search -- @param doc table with documentation -- @return table with documentation function directory (path, doc) for f in posix.dir(path) do local fullpath = path .. "/" .. f local attr = posix.stat(fullpath) assert(attr, string.format("error stating file `%s'", fullpath)) if attr.type == "reg" then doc = file(fullpath, doc) elseif attr.type == "dir" and f ~= "." and f ~= ".." then doc = directory(fullpath, doc) end end return doc end -- Recursively sorts the documentation table local function recsort (tab) table.sort (tab) -- sort list of functions by name alphabetically for f, doc in pairs(tab) do if doc.functions then table.sort(doc.functions) end if doc.tables then table.sort(doc.tables) end end end ------------------------------------------------------------------------------- function start (files, doc) assert(files, "file list not specified") -- Create an empty document, or use the given one doc = doc or { files = {}, modules = {}, } assert(doc.files, "undefined `files' field") assert(doc.modules, "undefined `modules' field") table.foreachi(files, function (_, path) local attr = posix.stat(path) assert(attr, string.format("error stating path `%s'", path)) if attr.type == "reg" then doc = file(path, doc) elseif attr.type == "dir" then doc = directory(path, doc) end end) -- order arrays alphabetically recsort(doc.files) recsort(doc.modules) return doc end
gpl-2.0
amir32002/feedback-networks
datasets/imagenet-gen.lua
5
3893
-- -- Copyright (c) 2016, Facebook, Inc. -- All rights reserved. -- -- This source code is licensed under the BSD-style license found in the -- LICENSE file in the root directory of this source tree. An additional grant -- of patent rights can be found in the PATENTS file in the same directory. -- -- Script to compute list of ImageNet filenames and classes -- -- This generates a file gen/imagenet.t7 which contains the list of all -- ImageNet training and validation images and their classes. This script also -- works for other datasets arragned with the same layout. -- local sys = require 'sys' local ffi = require 'ffi' local M = {} local function findClasses(dir) local dirs = paths.dir(dir) table.sort(dirs) local classList = {} local classToIdx = {} for _ ,class in ipairs(dirs) do if not classToIdx[class] and class ~= '.' and class ~= '..' then table.insert(classList, class) classToIdx[class] = #classList end end -- assert(#classList == 1000, 'expected 1000 ImageNet classes') return classList, classToIdx end local function findImages(dir, classToIdx) local imagePath = torch.CharTensor() local imageClass = torch.LongTensor() ---------------------------------------------------------------------- -- Options for the GNU and BSD find command local extensionList = {'jpg', 'png', 'jpeg', 'JPG', 'PNG', 'JPEG', 'ppm', 'PPM', 'bmp', 'BMP'} local findOptions = ' -iname "*.' .. extensionList[1] .. '"' for i=2,#extensionList do findOptions = findOptions .. ' -o -iname "*.' .. extensionList[i] .. '"' end -- Find all the images using the find command local f = io.popen('find -L ' .. dir .. findOptions) local maxLength = -1 local imagePaths = {} local imageClasses = {} -- Generate a list of all the images and their class while true do local line = f:read('*line') if not line then break end local className = paths.basename(paths.dirname(line)) local filename = paths.basename(line) local path = className .. '/' .. filename local classId = classToIdx[className] assert(classId, 'class not found: ' .. className) table.insert(imagePaths, path) table.insert(imageClasses, classId) maxLength = math.max(maxLength, #path + 1) end f:close() -- Convert the generated list to a tensor for faster loading local nImages = #imagePaths local imagePath = torch.CharTensor(nImages, maxLength):zero() for i, path in ipairs(imagePaths) do ffi.copy(imagePath[i]:data(), path) end local imageClass = torch.LongTensor(imageClasses) return imagePath, imageClass end function M.exec(opt, cacheFile) -- find the image path names local imagePath = torch.CharTensor() -- path to each image in dataset local imageClass = torch.LongTensor() -- class index of each image (class index in self.classes) local trainDir = paths.concat(opt.data, 'train') local valDir = paths.concat(opt.data, 'val') assert(paths.dirp(trainDir), 'train directory not found: ' .. trainDir) assert(paths.dirp(valDir), 'val directory not found: ' .. valDir) print("=> Generating list of images") local classList, classToIdx = findClasses(trainDir) print(" | finding all validation images") local valImagePath, valImageClass = findImages(valDir, classToIdx) print(" | finding all training images") local trainImagePath, trainImageClass = findImages(trainDir, classToIdx) local info = { basedir = opt.data, classList = classList, train = { imagePath = trainImagePath, imageClass = trainImageClass, }, val = { imagePath = valImagePath, imageClass = valImageClass, }, } print(" | saving list of images to " .. cacheFile) torch.save(cacheFile, info) return info end return M
mit
Proxmark/proxmark3
client/scripts/didump.lua
6
12186
local cmds = require('commands') local getopt = require('getopt') local utils = require('utils') local lib14a = require('read14a') example =[[ script run didump script run didump -k aabbccddeeff ]] author = "Iceman" usage = "script run didump -k <key> " desc = [[ This is a script to dump and decrypt the data of a specific type of Mifare Mini token. Arguments: -h : this help -k <key> : Mifare Key A. ]] local band=bit32.band local bor=bit32.bor local bnot=bit32.bnot local bxor=bit32.bxor local lshift=bit32.lshift local rshift=bit32.rshift local FOO = 'AF62D2EC0491968CC52A1A7165F865FE' local BAR = '286329204469736E65792032303133' local RANDOM = FOO..BAR local outputTemplate = os.date("toydump_%Y-%m-%d_%H%M%S"); local TIMEOUT = 2000 local DEBUG = false local numBlocks = 20 local numSectors = 5 local CHECKSUM_OFFSET = 12; -- +1??? --- -- A debug printout-function function dbg(args) if DEBUG then print("###", args) end end --- -- This is only meant to be used when errors occur function oops(err) print("ERROR: ",err) core.clearCommandBuffer() end --- -- Usage help function help() print(desc) print("Example usage") print(example) end --- -- Get checksum, -- called: data is string (32 hex digits) -- returns: number local function getChecksum(data) local chksum = data:sub(25,32) return tonumber(chksum,16) end --- -- calculate checksum -- called: data is bytes (24 hex digits) -- returns: number local function calculateChecksum(data) -- Generate table local _tbl = {} _tbl[0] = { 0x0 } _tbl[1] = { 0x77073096 } _tbl[2] = { 0xEE0E612C } _tbl[3] = { 0x990951BA } _tbl[4] = { 0x76DC419 } _tbl[5] = { 0x706AF48F } _tbl[6] = { 0xE963A535 } _tbl[7] = { 0x9E6495A3 } _tbl[8] = { 0xEDB8832 } _tbl[9] = { 0x79DCB8A4 } _tbl[10] = { 0xE0D5E91E } _tbl[11] = { 0x97D2D988 } _tbl[12] = { 0x9B64C2B } _tbl[13] = { 0x7EB17CBD } _tbl[14] = { 0xE7B82D07 } _tbl[15] = { 0x90BF1D91 } _tbl[16] = { 0x1DB71064 } _tbl[17] = { 0x6AB020F2 } _tbl[18] = { 0xF3B97148 } _tbl[19] = { 0x84BE41DE } _tbl[20] = { 0x1ADAD47D } _tbl[21] = { 0x6DDDE4EB } _tbl[22] = { 0xF4D4B551 } _tbl[23] = { 0x83D385C7 } _tbl[24] = { 0x136C9856 } _tbl[25] = { 0x646BA8C0 } _tbl[26] = { 0xFD62F97A } _tbl[27] = { 0x8A65C9EC } _tbl[28] = { 0x14015C4F } _tbl[29] = { 0x63066CD9 } _tbl[30] = { 0xFA0F3D63 } _tbl[31] = { 0x8D080DF5 } _tbl[32] = { 0x3B6E20C8 } _tbl[33] = { 0x4C69105E } _tbl[34] = { 0xD56041E4 } _tbl[35] = { 0xA2677172 } _tbl[36] = { 0x3C03E4D1 } _tbl[37] = { 0x4B04D447 } _tbl[38] = { 0xD20D85FD } _tbl[39] = { 0xA50AB56B } _tbl[40] = { 0x35B5A8FA } _tbl[41] = { 0x42B2986C } _tbl[42] = { 0xDBBBC9D6 } _tbl[43] = { 0xACBCF940 } _tbl[44] = { 0x32D86CE3 } _tbl[45] = { 0x45DF5C75 } _tbl[46] = { 0xDCD60DCF } _tbl[47] = { 0xABD13D59 } _tbl[48] = { 0x26D930AC } _tbl[49] = { 0x51DE003A } _tbl[50] = { 0xC8D75180 } _tbl[51] = { 0xBFD06116 } _tbl[52] = { 0x21B4F4B5 } _tbl[53] = { 0x56B3C423 } _tbl[54] = { 0xCFBA9599 } _tbl[55] = { 0xB8BDA50F } _tbl[56] = { 0x2802B89E } _tbl[57] = { 0x5F058808 } _tbl[58] = { 0xC60CD9B2 } _tbl[59] = { 0xB10BE924 } _tbl[60] = { 0x2F6F7C87 } _tbl[61] = { 0x58684C11 } _tbl[62] = { 0xC1611DAB } _tbl[63] = { 0xB6662D3D } _tbl[64] = { 0x76DC4190 } _tbl[65] = { 0x1DB7106 } _tbl[66] = { 0x98D220BC } _tbl[67] = { 0xEFD5102A } _tbl[68] = { 0x71B18589 } _tbl[69] = { 0x6B6B51F } _tbl[70] = { 0x9FBFE4A5 } _tbl[71] = { 0xE8B8D433 } _tbl[72] = { 0x7807C9A2 } _tbl[73] = { 0xF00F934 } _tbl[74] = { 0x9609A88E } _tbl[75] = { 0xE10E9818 } _tbl[76] = { 0x7F6A0DBB } _tbl[77] = { 0x86D3D2D } _tbl[78] = { 0x91646C97 } _tbl[79] = { 0xE6635C01 } _tbl[80] = { 0x6B6B51F4 } _tbl[81] = { 0x1C6C6162 } _tbl[82] = { 0x856530D8 } _tbl[83] = { 0xF262004E } _tbl[84] = { 0x6C0695ED } _tbl[85] = { 0x1B01A57B } _tbl[86] = { 0x8208F4C1 } _tbl[87] = { 0xF50FC457 } _tbl[88] = { 0x65B0D9C6 } _tbl[89] = { 0x12B7E950 } _tbl[90] = { 0x8BBEB8EA } _tbl[91] = { 0xFCB9887C } _tbl[92] = { 0x62DD1DDF } _tbl[93] = { 0x15DA2D49 } _tbl[94] = { 0x8CD37CF3 } _tbl[95] = { 0xFBD44C65 } _tbl[96] = { 0x4DB26158 } _tbl[97] = { 0x3AB551CE } _tbl[98] = { 0xA3BC0074 } _tbl[99] = { 0xD4BB30E2 } _tbl[100] = { 0x4ADFA541 } _tbl[101] = { 0x3DD895D7 } _tbl[102] = { 0xA4D1C46D } _tbl[103] = { 0xD3D6F4FB } _tbl[104] = { 0x4369E96A } _tbl[105] = { 0x346ED9FC } _tbl[106] = { 0xAD678846 } _tbl[107] = { 0xDA60B8D0 } _tbl[108] = { 0x44042D73 } _tbl[109] = { 0x33031DE5 } _tbl[110] = { 0xAA0A4C5F } _tbl[111] = { 0xDD0D7CC9 } _tbl[112] = { 0x5005713C } _tbl[113] = { 0x270241AA } _tbl[114] = { 0xBE0B1010 } _tbl[115] = { 0xC90C2086 } _tbl[116] = { 0x5768B525 } _tbl[117] = { 0x206F85B3 } _tbl[118] = { 0xB966D409 } _tbl[119] = { 0xCE61E49F } _tbl[120] = { 0x5EDEF90E } _tbl[121] = { 0x29D9C998 } _tbl[122] = { 0xB0D09822 } _tbl[123] = { 0xC7D7A8B4 } _tbl[124] = { 0x59B33D17 } _tbl[125] = { 0x2EB40D81 } _tbl[126] = { 0xB7BD5C3B } _tbl[127] = { 0xC0BA6CAD } _tbl[128] = { 0xEDB88320 } _tbl[129] = { 0x9ABFB3B6 } _tbl[130] = { 0x3B6E20C } _tbl[131] = { 0x74B1D29A } _tbl[132] = { 0xEAD54739 } _tbl[133] = { 0x9DD277AF } _tbl[134] = { 0x4DB2615 } _tbl[135] = { 0x73DC1683 } _tbl[136] = { 0xE3630B12 } _tbl[137] = { 0x94643B84 } _tbl[138] = { 0xD6D6A3E } _tbl[139] = { 0x7A6A5AA8 } _tbl[140] = { 0xE40ECF0B } _tbl[141] = { 0x9309FF9D } _tbl[142] = { 0xA00AE27 } _tbl[143] = { 0x7D079EB1 } _tbl[144] = { 0xF00F9344 } _tbl[145] = { 0x8708A3D2 } _tbl[146] = { 0x1E01F268 } _tbl[147] = { 0x6906C2FE } _tbl[148] = { 0xF762575D } _tbl[149] = { 0x806567CB } _tbl[150] = { 0x196C3671 } _tbl[151] = { 0x6E6B06E7 } _tbl[152] = { 0xFED41B76 } _tbl[153] = { 0x89D32BE0 } _tbl[154] = { 0x10DA7A5A } _tbl[155] = { 0x67DD4ACC } _tbl[156] = { 0xF9B9DF6F } _tbl[157] = { 0x8EBEEFF9 } _tbl[158] = { 0x17B7BE43 } _tbl[159] = { 0x60B08ED5 } _tbl[160] = { 0xD6D6A3E8 } _tbl[161] = { 0xA1D1937E } _tbl[162] = { 0x38D8C2C4 } _tbl[163] = { 0x4FDFF252 } _tbl[164] = { 0xD1BB67F1 } _tbl[165] = { 0xA6BC5767 } _tbl[166] = { 0x3FB506DD } _tbl[167] = { 0x48B2364B } _tbl[168] = { 0xD80D2BDA } _tbl[169] = { 0xAF0A1B4C } _tbl[170] = { 0x36034AF6 } _tbl[171] = { 0x41047A60 } _tbl[172] = { 0xDF60EFC3 } _tbl[173] = { 0xA867DF55 } _tbl[174] = { 0x316E8EEF } _tbl[175] = { 0x4669BE79 } _tbl[176] = { 0xCB61B38C } _tbl[177] = { 0xBC66831A } _tbl[178] = { 0x256FD2A0 } _tbl[179] = { 0x5268E236 } _tbl[180] = { 0xCC0C7795 } _tbl[181] = { 0xBB0B4703 } _tbl[182] = { 0x220216B9 } _tbl[183] = { 0x5505262F } _tbl[184] = { 0xC5BA3BBE } _tbl[185] = { 0xB2BD0B28 } _tbl[186] = { 0x2BB45A92 } _tbl[187] = { 0x5CB36A04 } _tbl[188] = { 0xC2D7FFA7 } _tbl[189] = { 0xB5D0CF31 } _tbl[190] = { 0x2CD99E8B } _tbl[191] = { 0x5BDEAE1D } _tbl[192] = { 0x9B64C2B0 } _tbl[193] = { 0xEC63F226 } _tbl[194] = { 0x756AA39C } _tbl[195] = { 0x26D930A } _tbl[196] = { 0x9C0906A9 } _tbl[197] = { 0xEB0E363F } _tbl[198] = { 0x72076785 } _tbl[199] = { 0x5005713 } _tbl[200] = { 0x95BF4A82 } _tbl[201] = { 0xE2B87A14 } _tbl[202] = { 0x7BB12BAE } _tbl[203] = { 0xCB61B38 } _tbl[204] = { 0x92D28E9B } _tbl[205] = { 0xE5D5BE0D } _tbl[206] = { 0x7CDCEFB7 } _tbl[207] = { 0xBDBDF21 } _tbl[208] = { 0x86D3D2D4 } _tbl[209] = { 0xF1D4E242 } _tbl[210] = { 0x68DDB3F8 } _tbl[211] = { 0x1FDA836E } _tbl[212] = { 0x81BE16CD } _tbl[213] = { 0xF6B9265B } _tbl[214] = { 0x6FB077E1 } _tbl[215] = { 0x18B74777 } _tbl[216] = { 0x88085AE6 } _tbl[217] = { 0xFF0F6A70 } _tbl[218] = { 0x66063BCA } _tbl[219] = { 0x11010B5C } _tbl[220] = { 0x8F659EFF } _tbl[221] = { 0xF862AE69 } _tbl[222] = { 0x616BFFD3 } _tbl[223] = { 0x166CCF45 } _tbl[224] = { 0xA00AE278 } _tbl[225] = { 0xD70DD2EE } _tbl[226] = { 0x4E048354 } _tbl[227] = { 0x3903B3C2 } _tbl[228] = { 0xA7672661 } _tbl[229] = { 0xD06016F7 } _tbl[230] = { 0x4969474D } _tbl[231] = { 0x3E6E77DB } _tbl[232] = { 0xAED16A4A } _tbl[233] = { 0xD9D65ADC } _tbl[234] = { 0x40DF0B66 } _tbl[235] = { 0x37D83BF0 } _tbl[236] = { 0xA9BCAE53 } _tbl[237] = { 0xDEBB9EC5 } _tbl[238] = { 0x47B2CF7F } _tbl[239] = { 0x30B5FFE9 } _tbl[240] = { 0xBDBDF21C } _tbl[241] = { 0xCABAC28A } _tbl[242] = { 0x53B39330 } _tbl[243] = { 0x24B4A3A6 } _tbl[244] = { 0xBAD03605 } _tbl[245] = { 0xCDD70693 } _tbl[246] = { 0x54DE5729 } _tbl[247] = { 0x23D967BF } _tbl[248] = { 0xB3667A2E } _tbl[249] = { 0xC4614AB8 } _tbl[250] = { 0x5D681B02 } _tbl[251] = { 0x2A6F2B94 } _tbl[252] = { 0xB40BBE37 } _tbl[253] = { 0xC30C8EA1 } _tbl[254] = { 0x5A05DF1B } _tbl[255] = { 0x2D02EF8D } -- Calculate it local ret = 0 for i,item in pairs(data) do local tmp = band(ret, 0xFF) local index = band( bxor(tmp, item), 0xFF) ret = bxor(rshift(ret,8), _tbl[index][1]) end return ret end --- -- update checksum -- called: data is string, ( >= 24 hex digits ) -- returns: string, (data concat new checksum) local function updateChecksum(data) local part = data:sub(1,24) local chksum = calculateChecksum( utils.ConvertHexToBytes(part)) return string.format("%s%X", part, chksum) end --- -- receives the answer from deviceside, used with a readblock command local function waitCmd() local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT) if response then local count,cmd,arg0 = bin.unpack('LL',response) if(arg0==1) then local count,arg1,arg2,data = bin.unpack('LLH511',response,count) return data:sub(1,32) else return nil, "Couldn't read block.." end end return nil, "No response from device" end local function selftest() local testdata = '000F42430D0A14000001D11F'..'5D738517' local chksum = getChecksum(testdata) local calc = calculateChecksum( utils.ConvertHexToBytes(testdata:sub(1,24))) print ('TESTDATA :: '..testdata) print ('DATA :: '..testdata:sub(1,24)) print (('CHKSUM :: %X'):format(chksum)) print (('CHKSUM CALC :: %X'):format(calc)) print ('UPDATE CHKSUM :: '..updateChecksum(testdata)) end --- -- The main entry point -- -d decrypt -- -e encrypt -- -v validate function main(args) local cmd, result, err, blockNo, keyA local blocks = {} local decryptkey = '' -- Read the parameters for o, a in getopt.getopt(args, 'hk:') do if o == "h" then help() return end if o == "k" then keyA = a end end selftest() local tst2 = '00100100030209094312356432324E34B79A349B' -- validate input args. keyA = keyA or '6dd747e86975' if #(keyA) ~= 12 then return oops( string.format('Wrong length of write key (was %d) expected 12', #keyA)) end -- Turn off Debug local cmdSetDbgOff = "hf mf dbg 0" core.console( cmdSetDbgOff) -- GET TAG UID result, err = lib14a.read14443a(false, true) if not result then return oops(err) end core.clearCommandBuffer() print(result.uid, keyA) local my = result.uid if 1 == 1 then return end -- Show tag info print((' Found tag %s'):format(result.name)) local longrandom = RANDOM..result.uid local res = utils.Sha1Hex(longrandom) res = utils.ConvertBytesToHex(utils.ConvertAsciiToBytes(res:sub(1,16))) decryptkey = utils.SwapEndiannessStr(res:sub(1,8) , 32) decryptkey = decryptkey..utils.SwapEndiannessStr( res:sub(9,16),32) decryptkey = decryptkey..utils.SwapEndiannessStr( res:sub(17,24),32) decryptkey = decryptkey..utils.SwapEndiannessStr( res:sub(25,32),32) print('Decrypt key::',decryptkey) print('Reading card data') print('Raw','Decrypted') for blockNo = 0, numBlocks-1, 1 do if core.ukbhit() then print("aborted by user") break end cmd = Command:new{cmd = cmds.CMD_MIFARE_READBL, arg1 = blockNo ,arg2 = 0,arg3 = 0, data = keyA} local err = core.SendCommand(cmd:getBytes()) if err then return oops(err) end local blockdata, err = waitCmd() if err then return oops(err) end if blockNo%4 ~= 3 then -- blocks with zero not encrypted. if string.find(blockdata, '^0+$') then print(blockdata, blockdata) else local aes = core.aes128_decrypt_ecb(decryptkey, blockdata) local bytes = utils.ConvertAsciiToBytes(aes) local hex = utils.ConvertBytesToHex(bytes) print(blockdata , hex) end elseif blockNo == 0 then print(blockdata,blockdata) else -- Sectorblocks, not encrypted local sectortrailer = keyA..blockdata:sub(13,20)..keyA print(sectortrailer, sectortrailer, blockdata:sub(13,20)) end end -- checksum fyra sista bytes i varje rad. (kanske inte för s0) -- s0b1,s1b0,s2b0,s3b0 -- end main(args)
gpl-2.0
amir32002/feedback-networks
lib/ConvLSTM_resnet5aifc.lua
1
12729
--[[ Convolutional LSTM for short term visual cell inputSize - number of input feature planes outputSize - number of output feature planes rho - recurrent sequence length stride - convolutional stride, used for the larger images input kc - convolutional filter size to convolve input km - convolutional filter size to convolve cell; usually km > kc --]] local _ = require 'moses' require 'nn' require 'dpnn' require 'rnn' require 'cudnn' local ConvLSTM, parent = torch.class('nn.ConvLSTM_resnet5aifc', 'nn.LSTM') function ConvLSTM:__init(inputSize, outputSize, rho, kc, km, stride, batchSize, p1, p2) self.p1 = p1 or 0 if p1 and p1 ~= 0 then assert(nn.Dropout(p1,false,false,true).lazy, 'only work with Lazy Dropout!') nn.Dropout(p1,false,false,true).flag = true end self.p2 = p2 or 0 if p2 and p2 ~= 0 then assert(nn.Dropout(p2,false,false,true).lazy, 'only work with Lazy Dropout!') nn.Dropout(p2,false,false,true).flag = true end self.mono = mono or false self.kc = kc self.km = km self.padc = torch.floor(kc/2) self.padm = torch.floor(km/2) self.stride = stride or 1 self.batchSize = batchSize or nil parent.__init(self, inputSize, outputSize, rho or 10) end -------------------------- factory methods ----------------------------- function ConvLSTM:buildGate() -- Note : Input is : {input(t), output(t-1), cell(t-1)} local gate = nn.Sequential() gate:add(nn.NarrowTable(1,2)) -- we don't need cell here local input2gate, output2gate if self.p1 ~= 0 then input2gate = nn.Sequential() :add(nn.Dropout(self.p1,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, self.kc, self.kc, self.stride, self.stride, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.kc, self.kc, 1, 1, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(nn.Dropout(self.p1,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) else input2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, self.kc, self.kc, self.stride, self.stride, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.kc, self.kc, 1, 1, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) end local para = nn.ParallelTable() para:add(input2gate):add(output2gate) gate:add(para) gate:add(nn.CAddTable()) gate:add(nn.Sigmoid()) return gate end function ConvLSTM:buildGate2() local gate = nn.Sequential() gate:add(nn.NarrowTable(1,2)) -- we don't need cell here local input2gate, output2gate if self.p1 ~= 0 then input2gate = nn.Sequential() :add(nn.Dropout(self.p1,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, self.kc, self.kc, self.stride, self.stride, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.kc, self.kc, 1, 1, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(nn.Dropout(self.p1,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) else input2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, 1, 1, self.stride, self.stride, 0, 0)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, 1, 1, 1, 1, 0, 0)) :add(nn.SpatialBatchNormalization(self.outputSize)) end local para = nn.ParallelTable() para:add(input2gate):add(output2gate) gate:add(para) gate:add(nn.CAddTable()) gate:add(nn.Sigmoid()) return gate end function ConvLSTM:buildInputGate() self.inputGate = self:buildGate2() return self.inputGate end function ConvLSTM:buildForgetGate() self.forgetGate = self:buildGate2() return self.forgetGate end function ConvLSTM:buildcellGate() -- Input is : {input(t), output(t-1), cell(t-1)}, but we only need {input(t), output(t-1)} local hidden = nn.Sequential() hidden:add(nn.NarrowTable(1,2)) local input2gate, output2gate if self.p2 ~= 0 then input2gate = nn.Sequential() :add(nn.Dropout(self.p2,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, self.kc, self.kc, self.stride, self.stride, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.kc, self.kc, 1, 1, self.padc, self.padc)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(nn.Dropout(self.p2,false,false,true,self.mono)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) :add(nn.ReLU(true)) :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, self.km, self.km, 1, 1, self.padm, self.padm):noBias()) :add(nn.SpatialBatchNormalization(self.outputSize)) else input2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.inputSize, self.outputSize, 1, 1, self.stride, self.stride, 0, 0)) :add(nn.SpatialBatchNormalization(self.outputSize)) output2gate = nn.Sequential() :add(cudnn.SpatialConvolution(self.outputSize, self.outputSize, 1, 1, 1, 1, 0, 0)) :add(nn.SpatialBatchNormalization(self.outputSize)) end local para = nn.ParallelTable() para:add(input2gate):add(output2gate) hidden:add(para) hidden:add(nn.CAddTable()) hidden:add(nn.Tanh()) self.cellGate = hidden return hidden end function ConvLSTM:buildcell() -- Input is : {input(t), output(t-1), cell(t-1)} self.inputGate = self:buildInputGate() self.forgetGate = self:buildForgetGate() self.cellGate = self:buildcellGate() -- forget = forgetGate{input, output(t-1), cell(t-1)} * cell(t-1) local forget = nn.Sequential() local concat = nn.ConcatTable() concat:add(self.forgetGate):add(nn.SelectTable(3)) forget:add(concat) forget:add(nn.CMulTable()) -- input = inputGate{input(t), output(t-1), cell(t-1)} * cellGate{input(t), output(t-1), cell(t-1)} local input = nn.Sequential() local concat2 = nn.ConcatTable() concat2:add(self.inputGate):add(self.cellGate) input:add(concat2) input:add(nn.CMulTable()) -- cell(t) = forget + input local cell = nn.Sequential() local concat3 = nn.ConcatTable() concat3:add(forget):add(input) cell:add(concat3) cell:add(nn.CAddTable()) self.cell = cell return cell end function ConvLSTM:buildOutputGate() self.outputGate = self:buildGate() return self.outputGate end -- cell(t) = cell{input, output(t-1), cell(t-1)} -- output(t) = outputGate{input, output(t-1)}*tanh(cell(t)) -- output of Model is table : {output(t), cell(t)} function ConvLSTM:buildModel() -- Input is : {input(t), output(t-1), cell(t-1)} self.cell = self:buildcell() self.outputGate = self:buildOutputGate() -- assemble local concat = nn.ConcatTable() concat:add(nn.NarrowTable(1,2)):add(self.cell) local model = nn.Sequential() model:add(concat) -- output of concat is {{input(t), output(t-1)}, cell(t)}, -- so flatten to {input(t), output(t-1), cell(t)} model:add(nn.FlattenTable()) local cellAct = nn.Sequential() cellAct:add(nn.SelectTable(3)) cellAct:add(nn.Tanh()) local concat3 = nn.ConcatTable() concat3:add(self.outputGate):add(cellAct) local output = nn.Sequential() output:add(concat3) output:add(nn.CMulTable()) -- we want the model to output : {output(t), cell(t)} local concat4 = nn.ConcatTable() concat4:add(output):add(nn.SelectTable(3)) model:add(concat4) return model end function ConvLSTM:updateOutput(input) local prevOutput, prevCell if self.step == 1 then prevOutput = self.userPrevOutput or self.zeroTensor prevCell = self.userPrevCell or self.zeroTensor if self.batchSize then self.zeroTensor:resize(input:size(1), self.outputSize,(input:size(3) + 2*self.padc -self.kc)/self.stride + 1,(input:size(4) + 2*self.padc - self.kc)/self.stride + 1):zero() else self.zeroTensor:resize(self.outputSize,input:size(2)/self.stride,input:size(3)/self.stride):zero() end else -- previous output and memory of this module prevOutput = self.output prevCell = self.cell if self.step > 2 then if self.step % 2 == 1 then local offset = 1 -- torch.randperm(self.outputSize-self.inputSize+1)[1] cTrans = nn.Sequential() :add(nn.SpatialUpSamplingNearest(self.stride)) :add(nn.Narrow(2,offset,self.inputSize)) local inputStar = self.prevOutput -- input = cTrans:forward(inputStar:float()):cuda() + input input = cTrans:forward(inputStar:double()):cuda() + input else input = input end end end --print(#input) --print(#prevOutput) --print(#prevCell) -- output(t), cell(t) = lstm{input(t), output(t-1), cell(t-1)} local output, cell if self.train ~= false then self:recycle() local recurrentModule = self:getStepModule(self.step) -- the actual forward propagation output, cell = unpack(recurrentModule:updateOutput{input, prevOutput, prevCell}) else output, cell = unpack(self.recurrentModule:updateOutput{input, prevOutput, prevCell}) end self.outputs[self.step] = output self.cells[self.step] = cell self.prevOutput = prevOutput --self.prevCell = prevCell self.output = output self.cell = cell self.step = self.step + 1 self.gradPrevOutput = nil self.updateGradInputStep = nil self.accGradParametersStep = nil self.gradParametersAccumulated = false -- note that we don't return the cell, just the output return self.output end function ConvLSTM:__tostring__() return string.format('%s(%d -> %d, iter = %d)', torch.type(self), self.inputSize, self.outputSize, self.rho) end function ConvLSTM:initBias(forgetBias, otherBias) local fBias = forgetBias or 1 local oBias = otherBias or 0 self.inputGate.modules[2].modules[1].bias:fill(oBias) self.outputGate.modules[2].modules[1].bias:fill(oBias) self.cellGate.modules[2].modules[1].bias:fill(oBias) self.forgetGate.modules[2].modules[1].bias:fill(fBias) end
mit
gajop/Zero-K
gamedata/modularcomms/dyncomm_chassis_generator.lua
2
4209
local chassisDefs = { { name = "dynstrike1", weapons = { "commweapon_peashooter", "commweapon_beamlaser", "commweapon_lparticlebeam", "commweapon_shotgun", "commweapon_shotgun_disrupt", "commweapon_disruptor", "commweapon_heavymachinegun", "commweapon_heavymachinegun_disrupt", "commweapon_missilelauncher", "commweapon_lightninggun", "commweapon_lightninggun_improved", "commweapon_peashooter", "commweapon_beamlaser", "commweapon_lparticlebeam", "commweapon_shotgun", "commweapon_shotgun_disrupt", "commweapon_disruptor", "commweapon_heavymachinegun", "commweapon_heavymachinegun_disrupt", "commweapon_missilelauncher", "commweapon_lightninggun", "commweapon_lightninggun_improved", "commweapon_multistunner", "commweapon_multistunner_improved", "commweapon_disruptorbomb", "commweapon_disintegrator", -- Space for shield } }, { name = "dynrecon1", weapons = { "commweapon_peashooter", "commweapon_beamlaser", "commweapon_lparticlebeam", "commweapon_disruptor", "commweapon_shotgun", "commweapon_shotgun_disrupt", "commweapon_lightninggun", "commweapon_lightninggun_improved", "commweapon_flamethrower", "commweapon_heavymachinegun", "commweapon_heavymachinegun_disrupt", "commweapon_multistunner", "commweapon_multistunner_improved", "commweapon_napalmgrenade", "commweapon_clusterbomb", "commweapon_disruptorbomb", "commweapon_concussion", -- Space for shield } }, { name = "dynsupport1", weapons = { "commweapon_peashooter", "commweapon_beamlaser", "commweapon_shotgun", "commweapon_shotgun_disrupt", "commweapon_lparticlebeam", "commweapon_disruptor", "commweapon_hparticlebeam", "commweapon_heavy_disruptor", "commweapon_lightninggun", "commweapon_lightninggun_improved", "commweapon_missilelauncher", "commweapon_shockrifle", "commweapon_multistunner", "commweapon_multistunner_improved", "commweapon_disruptorbomb", -- Space for shield } }, { name = "dynassault1", weapons = { "commweapon_peashooter", "commweapon_beamlaser", "commweapon_heatray", "commweapon_heavymachinegun", "commweapon_flamethrower", "commweapon_rocketlauncher", "commweapon_rocketlauncher_napalm", "commweapon_riotcannon", "commweapon_riotcannon_napalm", "commweapon_peashooter", "commweapon_beamlaser", "commweapon_heatray", "commweapon_heavymachinegun", "commweapon_flamethrower", "commweapon_rocketlauncher", "commweapon_rocketlauncher_napalm", "commweapon_riotcannon", "commweapon_riotcannon_napalm", "commweapon_hpartillery", "commweapon_hpartillery_napalm", "commweapon_disintegrator", "commweapon_napalmgrenade", "commweapon_slamrocket", "commweapon_clusterbomb", -- Space for shield } }, } local commanderCost = 1000 if (Spring.GetModOptions) then local modOptions = Spring.GetModOptions() if (modOptions and modOptions.commtest and modOptions.commtest ~= 0) then commanderCost = 100 end end local statOverrides = { cloakcost = 5, -- For personal cloak cloakcostmoving = 10, onoffable = true, -- For jammer and cloaker toggling canmanualfire = true, -- For manualfire weapons. buildcostmetal = commanderCost, buildcostenergy = commanderCost, buildtime = commanderCost, power = 1200, } for i = 1, #chassisDefs do local name = chassisDefs[i].name local unitDef = UnitDefs[name] for _, wreckDef in pairs(unitDef.featuredefs) do wreckDef.metal = wreckDef.metal*commanderCost/1200 wreckDef.reclaimtime = wreckDef.reclaimtime*commanderCost/1200 end for key, data in pairs(statOverrides) do unitDef[key] = data end for i = 1, 7 do unitDef.sfxtypes.explosiongenerators[i] = unitDef.sfxtypes.explosiongenerators[i] or [[custom:NONE]] end for num = 1, #chassisDefs[i].weapons do weaponName = chassisDefs[i].weapons[num] DynamicApplyWeapon(unitDef, weaponName, num) end if #chassisDefs[i].weapons > 31 then -- Limit of 31 for shield space. Spring.Echo("Too many commander weapons on:", name, "Limit is 31, found weapons:", #chassisDefs[i].weapons) end end
gpl-2.0
gajop/Zero-K
scripts/armca.lua
2
1097
include "constants.lua" local base = piece 'base' local emit = piece 'emit' local leftwing = piece 'leftwing' local rightwing = piece 'rightwing' local thrustb = piece 'thrustb' local smokePiece = {base, emit, thrustb} local nanoPieces = {emit} function script.Create() StartThread(SmokeUnit, smokePiece) Spring.SetUnitNanoPieces(unitID, nanoPieces) end function script.StartBuilding() SetUnitValue(COB.INBUILDSTANCE, 1) end function script.StopBuilding() SetUnitValue(COB.INBUILDSTANCE, 0) end function script.QueryNanoPiece() GG.LUPS.QueryNanoPiece(unitID,unitDefID,Spring.GetUnitTeam(unitID),emit) return nano end function script.Killed(recentDamage, maxHealth) local severity = recentDamage / maxHealth if severity <= 0.50 or ((Spring.GetUnitMoveTypeData(unitID).aircraftState or "") == "crashing") then Explode(rightwing, sfxSmoke) Explode(leftwing, sfxSmoke) return 1 else Explode(base, sfxShatter + sfxFire) Explode(rightwing, sfxFall + sfxSmoke + sfxFire + sfxExplodeOnHit) Explode(leftwing, sfxFall + sfxSmoke + sfxFire + sfxExplodeOnHit) return 2 end end
gpl-2.0
Zalgo2462/CSC542-DIP-1
ip.lua
1
136080
package.preload["argumentDialog"] = load( "\27LJ\1\2”\8\0\2\13\1(\0³\0017\2\0\1\7\2\1\0T\2Q€7\2\2\1\6\2\3\0T\2\3€7\2\2\1\14\0\2\0T\2\26€4\2\4\0007\2\5\2\16\3\0\0004\4\4\0007\4\6\4%\5\7\0004\6\4\0007\6\8\0064\7\4\0007\7\9\0074\8\4\0007\8\ \0087\9\11\1\14\0\9\0T\ \1€'\9\0\0007\ \12\1\14\0\ \0T\11\1€'\ d\0007\11\13\1\14\0\11\0T\12\1€'\11\0\0@\2\ \0T\2€7\2\2\1\7\2\14\0T\2\30€4\2\4\0007\2\15\2\16\3\0\0004\4\4\0007\4\6\0047\5\13\0017\6\11\1\14\0\6\0T\7\1€'\6\0\0007\7\12\1\14\0\7\0T\8\1€'\7d\0004\8\4\0007\8\8\0084\9\4\0007\9\16\9'\ ,\1'\0112\0>\9\3\0024\ \17\0007\ \18\ 4\11\4\0007\11\19\0114\12\4\0007\12\20\12>\ \3\0?\2\7\0T\2n€7\2\2\1\7\2\21\0T\2k€4\2\4\0007\2\22\2\16\3\0\0004\4\4\0007\4\6\0044\5\23\0007\6\13\1\14\0\6\0T\7\1€'\6\0\0>\5\2\0?\2\2\0T\2^€7\2\0\1\7\2\24\0T\2\16€4\2\4\0007\2\25\2\16\3\0\0004\4\4\0007\4\6\4%\5\7\0>\2\4\2\16\4\2\0007\3\26\0027\5\13\1\14\0\5\0T\6\1€)\5\1\0>\3\3\1H\2\2\0T\2K€7\2\0\1\7\2\27\0T\2\11€4\2\4\0007\2\22\2\16\3\0\0004\4\4\0007\4\6\0047\5\13\1\14\0\5\0T\6\1€%\5\7\0@\2\4\0T\2=€7\2\0\1\7\2\28\0T\2\27€4\2\4\0007\2\22\2\16\3\0\0004\4\4\0007\4\6\4%\5\29\0007\6\13\1\15\0\6\0T\7\13€7\6\13\0017\6\30\6\14\0\6\0T\7\ €'\6\0\0%\7\31\0007\8\13\0017\8 \8$\6\8\6\14\0\6\0T\7\3€'\6\0\0T\7\1€%\6!\0%\7\"\0$\5\7\5@\2\4\0T\2\31€7\2\0\1\6\2#\0T\2\3€7\2\0\1\7\2$\0T\2\12€4\2\4\0007\2%\2\16\3\0\0004\4\4\0007\4\6\0047\5\13\1\14\0\5\0T\6\2€+\5\0\0007\5$\5@\2\4\0T\2\13€7\2\0\1\7\2&\0T\2\ €4\2\4\0007\2'\2\16\3\0\0004\4\4\0007\4\6\0047\5\13\1\14\0\5\0T\6\1€%\5\7\0@\2\4\0G\0\1\0\1À\21wxFilePickerCtrl\ image\23wxColourPickerCtrl\11colour\ color\6)\0090, 0\6y\7, \6x\6(\ point\11string\13SetValue\15wxCheckBox\12boolean\13tostring\15wxTextCtrl\12textbox\16wxSL_LABELS\20wxSL_HORIZONTAL\8bor\ bit32\11wxSize\13wxSlider\11slider\12default\8max\8min\20wxSP_ARROW_KEYS\18wxDefaultSize\22wxDefaultPosition\5\13wxID_ANY\15wxSpinCtrl\7wx\9spin\16displaytype\11number\9type™\3\0\2\17\2\15\0@4\2\0\0007\2\1\0024\3\0\0007\3\2\3>\2\2\0024\3\0\0007\3\3\3\19\4\1\0'\5\2\0'\6\1\0'\7\20\0>\3\5\0022\4\0\0004\5\4\0\16\6\1\0>\5\2\4T\8\25€7\ \5\9\14\0\ \0T\11\3€+\ \0\0007\11\6\0096\ \11\ \16\12\3\0007\11\7\0034\13\0\0007\13\8\13\16\14\0\0004\15\0\0007\15\9\0157\16\ \9>\13\4\0=\11\1\1+\11\1\0\16\12\0\0\16\13\9\0>\11\3\2\16\13\3\0007\12\7\3\16\14\11\0>\12\3\0019\11\8\4A\8\3\3N\8å\127\16\6\2\0007\5\7\2\16\7\3\0>\5\3\1\16\6\2\0007\5\7\2\16\8\0\0007\7\11\0004\9\0\0007\9\12\0094\ \0\0007\ \13\ \30\9\ \9>\7\3\0=\5\1\1\16\6\0\0007\5\14\0\16\7\2\0>\5\3\1H\4\2\0\1À\2À\13SetSizer\13wxCANCEL\9wxOK\31CreateStdDialogButtonSizer\9name\13wxID_ANY\17wxStaticText\8Add\9type\12default\11ipairs\20wxFlexGridSizer\15wxVERTICAL\15wxBoxSizer\7wx\4\0\2\16\1\21\0S2\2\0\0004\3\0\0\16\4\0\0>\3\2\4T\6K€6\8\6\0017\8\1\0086\9\6\0017\9\2\9\7\8\3\0T\ \15€\7\9\4\0T\ \8€4\ \5\0\16\12\7\0007\11\6\7'\13\0\0>\11\3\0=\ \0\0029\ \6\2T\ ;€\16\11\7\0007\ \7\7>\ \2\0029\ \6\2T\ 6€\7\8\8\0T\ \5€\16\11\7\0007\ \7\7>\ \2\0029\ \6\2T\ /€\7\8\9\0T\ \6€\16\11\7\0007\ \6\7'\12\0\0>\ \3\0029\ \6\2T\ '€\7\8\ \0T\ \19€4\ \9\0007\ \11\ \16\12\7\0007\11\6\7'\13\0\0>\11\3\2%\12\12\0>\ \3\0034\12\13\0007\12\14\0124\13\5\0\16\14\ \0>\13\2\0024\14\5\0\16\15\11\0>\14\2\0=\12\1\0029\12\6\2T\ \18€\6\8\15\0T\ \2€\7\8\16\0T\ \5€\16\11\7\0007\ \17\7>\ \2\0029\ \6\2T\ \9€\7\8\18\0T\ \7€+\ \0\0007\ \19\ \16\12\7\0007\11\20\7>\11\2\0=\ \0\0029\ \6\2A\6\3\3N\6³\127H\2\2\0\0À\12GetPath\9open\ image\14GetColour\11colour\ color\12wxPoint\7wx\27\\(([0-9]+), ([0-9]+\\))\ match\ point\11string\12boolean\13GetValue\16GetLineText\13tonumber\12textbox\11number\16displaytype\9type\11ipairs­\1\0\1\6\2\7\0\0274\1\0\0007\1\1\0014\2\0\0007\2\2\0024\3\0\0007\3\3\3%\4\4\0>\1\4\2+\2\0\0\16\3\1\0\16\4\0\0>\2\3\2\16\4\1\0007\3\5\1>\3\2\0024\4\0\0007\4\6\4\5\3\4\0T\3\5€+\3\1\0\16\4\2\0\16\5\0\0@\3\3\0T\3\2€)\3\0\0H\3\2\0G\0\1\0\3À\4À\12wxID_OK\14ShowModal\14Arguments\13wxID_ANY\9NULL\13wxDialog\7wx³\1\3\0\6\0\12\0\0234\0\0\0%\1\1\0>\0\2\0023\1\2\0004\2\3\0007\2\4\2'\3\0\0'\4\0\0>\2\3\2:\2\5\0014\2\3\0007\2\6\2'\3\0\0'\4\0\0'\5\0\0>\2\4\2:\2\7\0011\2\8\0001\3\9\0001\4\ \0001\5\11\0000\0\0€H\5\2\0\0\0\0\0\11colour\13wxColour\ point\12wxPoint\7wx\1\0\3\12boolean\1\11string\5\11number\3\0\ image\12require\0" ) package.preload["fileMenu"] = load( "\27LJ\1\2Ç\1\0\1\8\0\ \0\0284\1\0\0007\1\1\1\16\2\0\0>\1\2\0024\2\2\0007\2\3\2%\3\4\0\16\4\3\0007\3\5\3\16\6\1\0007\5\6\1>\5\2\2\16\7\1\0007\6\7\1>\6\2\0=\3\2\0=\2\0\0014\2\2\0007\2\3\2\16\3\0\0%\4\8\0$\3\4\3>\2\2\0014\2\9\0\16\3\1\0\16\4\0\0>\2\3\1G\0\1\0\13addImage\6\ \14GetHeight\13GetWidth\11format\27loaded %d by %d image\ \ write\7io\12wxImage\7wx5\0\1\5\0\2\0\0074\1\0\0>\1\1\2\16\3\1\0007\2\1\1\16\4\0\0>\2\3\1G\0\1\0\13SaveFile\13getImageï\1\0\0\8\0\12\0\0274\0\0\0007\0\1\0004\1\2\0%\2\3\0%\3\4\0%\4\4\0%\5\5\0004\6\0\0007\6\6\0064\7\0\0007\7\7\7\30\6\7\6>\0\7\2\16\2\0\0007\1\8\0>\1\2\0024\2\0\0007\2\9\2\5\1\2\0T\1\1€G\0\1\0004\1\ \0\16\3\0\0007\2\11\0>\2\2\0=\1\0\1G\0\1\0\12GetPath\14loadImage\16wxID_CANCEL\14ShowModal\25wxFD_FILE_MUST_EXIST\14wxFD_OPEN\18All files|*.*\5\20Open Image File\ frame\17wxFileDialog\7wxÉ\1\0\0\7\0\11\0\0244\0\0\0007\0\1\0004\1\2\0%\2\3\0%\3\4\0%\4\4\0%\5\5\0004\6\0\0007\6\6\6>\0\7\2\16\2\0\0007\1\7\0>\1\2\0024\2\0\0007\2\8\2\5\1\2\0T\1\1€G\0\1\0004\1\9\0\16\3\0\0007\2\ \0>\2\2\0=\1\0\1G\0\1\0\12GetPath\14saveImage\16wxID_CANCEL\14ShowModal\14wxFD_SAVE\18All files|*.*\5\15Save Image\ frame\17wxFileDialog\7wx<\0\0\2\0\3\0\0074\0\0\0007\0\1\0>\0\1\2\16\1\0\0007\0\2\0>\0\2\1G\0\1\0\17ExitMainLoop\13wxGetApp\7wx­\4\3\0\12\0\26\0S4\0\0\0007\0\1\0>\0\1\0024\1\2\0>\1\1\0024\2\0\0007\2\3\2\16\3\0\0\16\4\1\0%\5\4\0%\6\5\0>\2\5\0024\3\2\0>\3\1\0024\4\0\0007\4\3\4\16\5\0\0\16\6\3\0%\7\6\0%\8\7\0>\4\5\0024\5\2\0>\5\1\0024\6\0\0007\6\3\6\16\7\0\0\16\8\5\0%\9\8\0%\ \9\0>\6\5\0024\7\ \0\16\8\7\0007\7\11\7\16\9\0\0%\ \12\0>\7\4\1\16\8\0\0007\7\11\0\16\9\2\0>\7\3\1\16\8\0\0007\7\11\0\16\9\4\0>\7\3\1\16\8\0\0007\7\11\0\16\9\6\0>\7\3\0011\7\13\0005\7\14\0001\7\15\0005\7\16\0001\7\17\0005\7\18\0001\7\19\0005\7\20\0001\7\21\0005\7\22\0004\7\23\0\16\8\7\0007\7\24\7\16\9\1\0004\ \0\0007\ \25\ 4\11\18\0>\7\5\0014\7\23\0\16\8\7\0007\7\24\7\16\9\3\0004\ \0\0007\ \25\ 4\11\20\0>\7\5\0014\7\23\0\16\8\7\0007\7\24\7\16\9\5\0004\ \0\0007\ \25\ 4\11\22\0>\7\5\1G\0\1\0 wxEVT_COMMAND_MENU_SELECTED\12Connect\ frame\12exitApp\0\13saveFile\0\13openFile\0\14saveImage\0\14loadImage\0\9File\11Append\12menubar\25Exit the application\9Exit\18Save an image\16Save\9CTRL+S\18Open an image\16Open\9CTRL+O\15wxMenuItem\ newID\11wxMenu\7wx\0" ) package.preload["image"] = load( "\27LJ\1\2?\0\2\7\0\4\0\0114\2\0\0007\3\1\0007\4\1\1\30\3\4\0037\4\2\0007\5\2\1\30\4\5\0047\5\3\0007\6\3\1\30\5\6\5@\2\4\0\6b\6g\6r\ pixel?\0\2\7\0\4\0\0114\2\0\0007\3\1\0007\4\1\1\31\3\4\0037\4\2\0007\5\2\1\31\4\5\0047\5\3\0007\6\3\1\31\5\6\5@\2\4\0\6b\6g\6r\ pixel3\0\2\6\0\4\0\0084\2\0\0007\3\1\1 \3\3\0007\4\2\1 \4\4\0007\5\3\1 \5\5\0@\2\4\0\6b\6g\6r\ pixelÒ\1\0\3\ \0\6\0\30'\3\0\0\0\1\3\0T\3\9€7\3\0\0\2\3\1\0T\3\6€'\3\0\0\0\2\3\0T\3\3€7\3\1\0\3\3\2\0T\3\11€4\3\2\0%\4\3\0\16\5\4\0007\4\4\4\16\6\1\0\16\7\2\0007\8\1\0007\9\0\0>\4\6\0=\3\0\1T\3\6€7\3\5\0007\4\1\0 \4\4\1\30\4\2\0046\3\4\3H\3\2\0G\0\1\0\9data\11format8position (%d, %d) out of bounds on image (%d by %d)\ error\ width\11height{\0\1\7\1\7\1\18+\1\0\0007\1\0\0017\2\1\0007\3\2\0007\4\3\0 \3\4\3\22\3\0\3>\1\3\0024\2\4\0007\2\5\0027\3\2\0007\4\3\0\16\5\1\0)\6\2\0>\2\5\2\16\3\2\0007\2\6\2@\2\2\0\0À\9Copy\12wxImage\7wx\11height\ width\9data\11string\6„\1\0\2\17\0\6\1\0257\2\0\0007\3\1\0'\4\0\0\21\5\0\3'\6\1\0I\4\18€'\8\0\0\21\9\0\2'\ \1\0I\8\13€7\12\2\0 \13\7\2\30\13\11\0136\12\13\12\16\13\1\0007\14\3\0127\15\4\0127\16\5\12>\13\4\4:\15\5\12:\14\4\12:\13\3\12K\8ó\127K\4î\127H\0\2\0\6b\6g\6r\9data\11height\ width\2n\0\0\4\5\0\1\23+\0\0\0+\1\1\0+\2\0\0+\3\2\0\3\3\2\0T\2\2€)\2\0\0H\2\2\0+\2\1\0\20\2\0\2,\1\2\0+\2\1\0+\3\3\0\3\3\2\0T\2\5€+\2\0\0\20\2\0\2+\3\4\0,\1\3\0,\0\2\0\16\2\0\0\16\3\1\0F\2\3\0\2€\3€\5À\4À\1€\2E\1\2\7\0\3\0\12\14\0\1\0T\2\1€'\1\0\0\16\2\1\0\16\3\1\0007\4\0\0\31\4\1\0047\5\1\0\31\5\1\0051\6\2\0000\0\0€H\6\2\0\0\11height\ width˜\1\0\1\9\2\8\1\0247\1\0\0007\2\1\0 \1\2\1\22\1\0\1+\2\0\0007\2\2\0027\2\3\2\16\3\1\0>\2\2\2+\3\0\0007\3\4\3\16\4\2\0007\5\5\0\16\6\1\0>\3\4\1+\3\1\0007\4\0\0007\5\1\0+\6\0\0007\6\6\6%\7\7\0\16\8\2\0>\6\3\0?\3\2\0\0À\2€\11pixel*\9cast\9data\9copy\11malloc\6C\11height\ width\6:\0\2\5\0\2\0\8\16\3\0\0007\2\0\0>\2\2\2\16\3\2\0007\2\1\2\16\4\1\0>\2\3\1G\0\1\0\13SaveFile\14towxImage5\0\1\3\1\3\0\8+\1\0\0007\1\0\0017\1\1\0017\2\2\0>\1\2\1)\1\0\0:\1\2\0G\0\1\0\0À\9data\9free\6CÉ\1\0\1\9\2\8\1\"\16\2\0\0007\1\0\0>\1\2\2\16\3\0\0007\2\1\0>\2\2\2 \1\2\1\22\1\0\1+\2\0\0007\2\2\0027\2\3\2\16\3\1\0>\2\2\2+\3\0\0007\3\4\3\16\4\2\0\16\6\0\0007\5\5\0>\5\2\2\16\6\1\0>\3\4\1+\3\1\0\16\5\0\0007\4\0\0>\4\2\2\16\6\0\0007\5\1\0>\5\2\2+\6\0\0007\6\6\6%\7\7\0\16\8\2\0>\6\3\0?\3\2\0\0À\2€\11pixel*\9cast\12GetData\9copy\11malloc\6C\14GetHeight\13GetWidth\6±\2\0\5\12\2\ \2> \5\1\0\22\5\0\5+\6\0\0007\6\0\6%\7\1\0+\8\0\0007\8\2\0087\8\3\8\16\9\5\0>\8\2\0=\6\1\2\14\0\2\0T\7\7€+\7\0\0007\7\4\7\16\8\6\0\16\9\5\0'\ \0\0>\7\4\1T\7%€4\7\5\0\16\8\2\0>\7\2\2\7\7\6\0T\7\9€\14\0\3\0T\7\7€+\7\0\0007\7\4\7\16\8\6\0\16\9\5\0\16\ \2\0>\7\4\1T\7\23€\14\0\3\0T\7\12€7\7\7\2\12\4\7\0T\8\1€8\4\3\0027\7\8\2\12\3\7\0T\8\1€8\3\2\0027\7\9\2\12\2\7\0T\8\1€8\2\1\2'\7\0\0\21\8\1\5'\9\1\0I\7\5€6\11\ \6:\2\9\11:\3\8\11:\4\7\11K\7û\127+\7\1\0\16\8\0\0\16\9\1\0\16\ \6\0@\7\4\0\0À\2€\6r\6g\6b\11number\9type\9fill\11malloc\6C\11pixel*\9cast\6\2,\0\1\4\1\2\0\6+\1\0\0004\2\0\0007\2\1\2\16\3\0\0>\2\2\0?\1\0\0\3À\12wxImage\7wx’\7\3\0\8\0'\00024\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0017\1\3\0%\2\4\0>\1\2\0017\1\5\0%\2\6\0003\3\8\0001\4\7\0:\4\9\0031\4\ \0:\4\11\0031\4\12\0:\4\13\3>\1\3\2)\2\0\0007\3\5\0%\4\14\0003\5\28\0003\6\16\0001\7\15\0:\7\17\0061\7\18\0:\7\19\0061\7\20\0:\7\21\0061\7\22\0:\7\23\0061\7\24\0:\7\25\0061\7\26\0:\7\27\6:\6\29\0051\6\30\0:\6\31\5>\3\3\2\16\2\3\0001\3 \0001\4!\0001\5\"\0003\6#\0:\3$\6:\4%\6:\5&\0060\0\0€H\6\2\0\9open\9flat\16fromwxImage\1\0\0\0\0\0\9__gc\0\12__index\1\0\0\ write\0\ clone\0\11pixels\0\14mapPixels\0\14towxImage\0\7at\1\0\0\0\ image\ __mul\0\ __sub\0\ __add\1\0\0\0\ pixel\13metatype¥\4void *malloc(size_t);\ \ void free(void *);\ \ typedef struct pixel {\ union {\ struct {\ union {\ uint8_t r;\ uint8_t y;\ uint8_t i;\ };\ union {\ uint8_t g;\ uint8_t in;\ uint8_t u;\ uint8_t h;\ };\ union {\ uint8_t b;\ uint8_t q;\ uint8_t v;\ uint8_t s;\ };\ };\ uint8_t rgb[3];\ uint8_t yiq[3];\ uint8_t yuv[3];\ uint8_t ihs[3];\ };\ } pixel;\ \ typedef struct image {\ int width;\ int height;\ pixel *data;\ } image;\ \9cdef\7wx\8ffi\12require\0" ) package.preload["imageview"] = load( "\27LJ\1\2\4\0\1\12\2\18\1U\16\2\0\0007\1\0\0>\1\2\2\16\2\1\0007\1\1\1%\3\2\0>\1\3\2\16\3\1\0007\2\3\1>\2\2\2+\3\0\0006\3\2\3+\4\0\0006\4\2\0047\4\4\4\16\6\0\0007\5\5\0'\7\2\0>\5\3\1\16\6\0\0007\5\6\0>\5\2\2\15\0\5\0T\6\16€\16\6\0\0007\5\7\0>\5\2\2\15\0\5\0T\6\11€\16\6\0\0007\5\8\0>\5\2\2%\6\9\0\16\7\6\0007\6\ \6>\6\2\2\5\5\6\0T\5\2€\22\4\0\4T\5\19€\16\6\0\0007\5\6\0>\5\2\2\15\0\5\0T\6\11€\16\6\0\0007\5\8\0>\5\2\2%\6\11\0\16\7\6\0007\6\ \6>\6\2\2\5\5\6\0T\5\2€\23\4\0\4T\5\3€4\5\12\0\16\6\0\0>\5\2\1+\5\0\0006\5\2\5:\4\4\5\16\6\1\0007\5\13\1+\7\1\0+\8\1\0007\9\14\3\16\ \9\0007\9\15\9>\9\2\2 \9\4\9+\ \1\0!\9\ \0097\ \14\3\16\11\ \0007\ \16\ >\ \2\2 \ \4\ +\11\1\0!\ \11\ >\5\6\1\16\6\1\0007\5\17\1>\5\2\1G\0\1\0\0À\1À\12Refresh\14GetHeight\13GetWidth\11bitmap\18SetScrollbars\17handleHotkey\6-\9byte\6=\15GetKeyCode\14ShiftDown\16ControlDown\22ResumePropagation\9zoom\ GetId\21wxScrolledWindow\16DynamicCast\19GetEventObject\4\2\0\1\ \1\12\0$\16\2\0\0007\1\0\0>\1\2\2\16\2\1\0007\1\1\1%\3\2\0>\1\3\0024\2\3\0007\2\4\2\16\3\1\0>\2\2\2\16\4\1\0007\3\5\1\16\5\2\0>\3\3\1+\3\0\0\16\5\1\0007\4\6\1>\4\2\0026\3\4\3\16\5\2\0007\4\7\0027\6\8\0037\7\8\3>\4\4\1\16\5\2\0007\4\9\0027\6\ \3'\7\0\0'\8\0\0)\9\1\0>\4\6\1\16\5\2\0007\4\11\2>\4\2\1G\0\1\0\0À\11delete\11bitmap\15DrawBitmap\9zoom\17SetUserScale\ GetId\14PrepareDC\14wxPaintDC\7wx\21wxScrolledWindow\16DynamicCast\19GetEventObjectg\0\1\4\0\4\0\11\16\2\0\0007\1\0\0>\1\2\2\16\2\1\0007\1\1\1%\3\2\0>\1\3\2\16\3\1\0007\2\3\1>\2\2\1G\0\1\0\12Refresh\21wxScrolledWindow\16DynamicCast\19GetEventObject…\1\0\1\5\1\5\0\22\16\2\0\0007\1\0\0>\1\2\2\16\3\1\0007\2\1\1>\2\2\2+\3\0\0006\3\2\0037\3\2\3\16\4\3\0007\3\3\3>\3\2\1+\3\0\0006\3\2\0037\3\4\3\16\4\3\0007\3\3\3>\3\2\1+\3\0\0)\4\0\0009\4\2\3G\0\1\0\0À\ image\11delete\11bitmap\ GetId\14GetWindow¢\4\0\5\15\6\24\0N4\5\0\0007\5\1\0054\6\2\0\16\7\2\0>\6\2\2%\7\3\0$\6\7\6>\5\2\1\16\6\2\0007\5\4\2>\5\2\2\16\7\2\0007\6\5\2>\6\2\2\14\0\1\0T\7\2€4\7\6\0007\1\7\0074\7\6\0007\7\8\7\16\8\0\0\16\9\1\0004\ \6\0007\ \9\ 4\11\6\0007\11\ \11\16\12\5\0\16\13\6\0>\11\3\0=\7\3\0024\8\6\0007\8\11\8\16\9\2\0>\8\2\2\16\ \7\0007\9\12\7+\11\0\0+\12\0\0+\13\0\0!\13\13\5+\14\0\0!\14\14\6>\9\6\1\16\ \7\0007\9\13\0074\11\6\0007\11\14\11+\12\1\0>\9\4\1\16\ \7\0007\9\13\0074\11\6\0007\11\15\11+\12\2\0>\9\4\1\16\ \7\0007\9\13\0074\11\6\0007\11\16\11+\12\3\0>\9\4\1\16\ \7\0007\9\13\0074\11\6\0007\11\17\11+\12\4\0>\9\4\1+\9\5\0\16\11\7\0007\ \18\7>\ \2\0023\11\19\0:\2\20\11:\8\21\11:\3\22\11:\4\23\0119\11\ \9H\7\2\0\1À\2À\3À\4À\5À\0À\9name\9path\11bitmap\ image\1\0\1\9zoom\3\1\ GetId\18wxEVT_DESTROY\15wxEVT_SIZE\16wxEVT_PAINT\19wxEVT_KEY_DOWN\12Connect\18SetScrollbars\13wxBitmap\11wxSize\22wxDefaultPosition\21wxScrolledWindow\13wxID_ANY\7wx\14GetHeight\13GetWidth\6\ \13tostring\ write\7io\2\0\2\13\2\12\0'\16\3\0\0007\2\0\0>\2\2\2+\3\0\0006\3\2\3:\1\1\0037\4\2\3\16\5\4\0007\4\3\4>\4\2\0014\4\4\0007\4\5\4\16\5\1\0>\4\2\2:\4\2\3\16\5\1\0007\4\6\1>\4\2\2\16\6\1\0007\5\7\1>\5\2\2\16\7\0\0007\6\8\0%\8\9\0>\6\3\2\16\7\6\0007\6\ \6+\8\1\0+\9\1\0007\ \11\3 \ \ \4+\11\1\0!\ \11\ 7\11\11\3 \11\11\5+\12\1\0!\11\12\11>\6\6\1G\0\1\0\0À\1À\9zoom\18SetScrollbars\21wxScrolledWindow\16DynamicCast\14GetHeight\13GetWidth\13wxBitmap\7wx\11delete\11bitmap\ image\ GetId1\0\1\4\1\2\0\7+\1\0\0\16\3\0\0007\2\0\0>\2\2\0026\1\2\0017\1\1\1H\1\2\0\0À\ image\ GetId0\0\1\4\1\2\0\7+\1\0\0\16\3\0\0007\2\0\0>\2\2\0026\1\2\0017\1\1\1H\1\2\0\0À\9path\ GetId0\0\1\4\1\2\0\7+\1\0\0\16\3\0\0007\2\0\0>\2\2\0026\1\2\0017\1\1\1H\1\2\0\0À\9name\ GetId…\1\3\0\12\0\15\0\0192\0\0\0'\1 \0001\2\0\0001\3\1\0001\4\2\0001\5\3\0001\6\4\0001\7\5\0001\8\6\0001\9\7\0001\ \8\0003\11\9\0:\6\ \11:\7\11\11:\8\12\11:\9\13\11:\ \14\0110\0\0€H\11\2\0\12getName\12getPath\13getImage\13setImage\8new\1\0\0\0\0\0\0\0\0\0\0\0\0" ) package.preload["mainpanel"] = load( "\27LJ\1\2\"\0\1\3\0\1\0\3\16\2\0\0007\1\0\0@\1\2\0\19GetCurrentPageÄ\1\0\3\12\2\11\0\0284\3\0\0007\3\1\3%\4\2\0\16\5\2\0%\6\3\0$\4\6\4>\3\2\0014\3\4\0007\3\5\3\16\4\2\0%\5\6\0>\3\3\2\16\5\0\0007\4\7\0+\6\0\0007\6\8\6\16\7\0\0004\8\9\0007\8\ \8\16\9\1\0\16\ \2\0\16\11\3\0>\6\6\2\16\7\3\0)\8\2\0+\9\1\0>\4\6\1G\0\1\0\0À\2À\13wxID_ANY\7wx\8new\12AddPage\14([^\\/]+)$\ match\11string\6\ \19creating tab: \ write\7ioã\1\0\1\11\2\11\0!\16\2\0\0007\1\0\0>\1\2\2+\2\0\0007\2\1\2\16\3\1\0>\2\2\0024\3\2\0007\3\3\3\16\4\2\0%\5\4\0>\3\3\2\16\5\0\0007\4\5\0+\6\0\0007\6\6\6\16\7\0\0004\8\7\0007\8\8\8+\9\0\0007\9\9\9\16\ \1\0>\9\2\2\16\ \9\0007\9\ \9>\9\2\2\16\ \2\0>\6\5\2\16\7\3\0)\8\2\0+\9\1\0>\4\6\1G\0\1\0\0À\2À\9Copy\13getImage\13wxID_ANY\7wx\8new\12AddPage\14([^\\/]+)$\ match\11string\12getPath\19GetCurrentPagep\0\1\7\1\5\0\15\16\2\0\0007\1\0\0>\1\2\2+\2\0\0007\2\1\2\16\3\1\0004\4\2\0007\4\3\4+\5\0\0007\5\4\5\16\6\1\0>\5\2\0=\4\0\0=\2\1\1G\0\1\0\0À\12getPath\12wxImage\7wx\13setImage\19GetCurrentPage\27\0\1\3\2\0\0\4+\1\0\0+\2\1\0>\1\2\1G\0\1\0\2\0\2À\27\0\1\3\2\0\0\4+\1\0\0+\2\1\0>\1\2\1G\0\1\0\3\0\2ÀÝ\2\1\1\9\4\15\0/\16\2\0\0007\1\0\0>\1\2\2\16\2\1\0007\1\1\1%\3\2\0>\1\3\2\16\3\1\0007\2\3\1>\2\2\2\16\3\2\0007\2\1\2%\4\4\0>\2\3\0024\3\5\0007\3\6\3>\3\1\2\16\5\3\0007\4\7\3+\6\0\0%\7\8\0>\4\4\1\16\5\3\0007\4\7\3+\6\1\0%\7\9\0>\4\4\1\16\5\3\0007\4\ \3+\6\0\0004\7\5\0007\7\11\0071\8\12\0>\4\5\1\16\5\3\0007\4\ \3+\6\1\0004\7\5\0007\7\11\0071\8\13\0>\4\5\1\16\5\2\0007\4\14\2\16\6\3\0>\4\3\0010\0\0€G\0\1\0\3À\4À\7À\8À\14PopupMenu\0\0 wxEVT_COMMAND_MENU_SELECTED\12Connect\11Reload\14Duplicate\11Append\11wxMenu\7wx\18wxAuiNotebook\14GetParent\17wxAuiTabCtrl\16DynamicCast\19GetEventObject’\3\0\1\5\2\15\0=4\1\0\0007\1\1\1%\2\2\0>\1\2\1\16\2\0\0007\1\3\0>\1\2\2\16\2\1\0007\1\4\1%\3\5\0>\1\3\2\16\2\1\0007\1\6\1>\1\2\2\16\2\1\0007\1\4\1%\3\7\0>\1\3\2\16\3\0\0007\2\8\0>\2\2\2\15\0\2\0T\3\13€\16\3\0\0007\2\9\0>\2\2\2%\3\ \0\16\4\3\0007\3\11\3>\3\2\2\5\2\3\0T\2\4€+\2\0\0\16\3\1\0>\2\2\1T\2\21€\16\3\0\0007\2\8\0>\2\2\2\15\0\2\0T\3\13€\16\3\0\0007\2\9\0>\2\2\2%\3\12\0\16\4\3\0007\3\11\3>\3\2\2\5\2\3\0T\2\4€+\2\1\0\16\3\1\0>\2\2\1T\2\3€4\2\13\0\16\3\0\0>\2\2\1\16\3\1\0007\2\14\1>\2\2\1G\0\1\0\7À\8À\12Refresh\17handleHotkey\6R\9byte\6D\15GetKeyCode\16ControlDown\18wxAuiNotebook\14GetParent\13wxWindow\16DynamicCast\19GetEventObject\29handling panel keypress\ \ write\7ioÝ\1\0\2\9\2\8\0\0254\2\0\0007\2\1\2\16\3\0\0\16\4\1\0004\5\2\0007\5\3\0054\6\2\0007\6\4\6'\7€\7'\0088\4>\6\3\0=\2\3\2\16\4\2\0007\3\5\0024\5\0\0007\5\6\5+\6\0\0>\3\4\1\16\4\2\0007\3\5\0024\5\2\0007\5\7\5+\6\1\0>\3\4\1H\2\2\0\9À\ À\19wxEVT_KEY_DOWN+wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP\12Connect\11wxSize\22wxDefaultPosition\7wx\18wxAuiNotebook\ wxaui°\2\3\0\13\0\22\0$4\0\0\0%\1\1\0>\0\2\0022\1\0\0004\2\2\0007\2\3\0027\2\4\0024\3\2\0007\3\5\0034\4\2\0007\4\6\0044\5\2\0007\5\7\5'\6\16\0'\7\16\0>\5\3\0=\2\2\0024\3\8\0>\3\1\0024\4\8\0>\4\1\0021\5\9\0001\6\ \0001\7\11\0001\8\12\0001\9\13\0001\ \14\0001\11\15\0003\12\16\0:\11\17\12:\5\18\12:\6\19\12:\7\20\12:\8\21\0120\0\0€H\12\2\0\15reloadView\18duplicateView\16openNewView\18getActiveView\8new\1\0\0\0\0\0\0\0\0\0\ newID\11wxSize\16wxART_OTHER\22wxART_NORMAL_FILE\14GetBitmap\18wxArtProvider\7wx\14imageview\12require\0" ) package.preload["menuCreator"] = load( "\27LJ\1\2¬\1\0\0\6\4\1\0$*\0\1\0+\2\0\0+\3\1\0006\2\3\0028\2\3\2\15\0\2\0T\3\8€)\1\2\0+\2\2\0+\3\0\0+\4\1\0006\3\4\0038\3\3\3>\2\2\2\16\0\2\0\15\0\1\0T\2\12€\15\0\0\0T\2\16€4\2\0\0+\3\0\0+\4\1\0006\3\4\0038\3\2\3+\4\3\0\16\5\0\0>\4\2\0=\2\1\1T\2\6€4\2\0\0+\3\0\0+\4\1\0006\3\4\0038\3\2\3>\2\2\1G\0\1\0\1À\6À\0\0\1\0\17processImageõ\2\1\2\15\2\13\00094\2\0\0007\2\1\2>\2\1\2'\3\1\0\19\4\1\0'\5\1\0I\3*€4\7\2\0>\7\1\0024\8\0\0007\8\3\8\16\9\2\0\16\ \7\0006\11\6\0018\11\1\11>\8\4\0026\9\6\0018\9\2\9\14\0\9\0T\9\6€4\9\4\0%\ \5\0006\11\6\0018\11\1\11$\ \11\ >\9\2\1\16\ \2\0007\9\6\2\16\11\8\0>\9\3\0011\9\7\0\16\11\2\0007\ \8\2\16\12\7\0004\13\0\0007\13\9\13\16\14\9\0>\ \5\0016\ \6\0017\ \ \ \15\0\ \0T\11\5€4\ \11\0006\11\6\0017\11\ \11\16\12\9\0>\ \3\0010\6\0€K\3Ö\1274\3\12\0\16\4\3\0007\3\6\3\16\5\2\0\16\6\0\0>\3\4\0010\0\0€G\0\1\0\0À\1À\12menubar\14setHotkey\11hotkey wxEVT_COMMAND_MENU_SELECTED\12Connect\0\11Append$missing function for menu item \ error\15wxMenuItem\ newID\11wxMenu\7wxf\3\0\3\0\6\0\0124\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\1\14\0\1\0T\2\1€4\1\3\0001\2\4\0005\2\5\0000\0\0€G\0\1\0\14imageMenu\0\11unpack\ table\19argumentDialog\12require\0" ) package.preload["visual"] = load( "\27LJ\1\2\30\0\0\1\1\0\1\5+\0\0\0\20\0\0\0,\0\0\0+\0\0\0H\0\2\0\1€\2$\0\1\3\1\1\0\5+\1\0\0\16\2\1\0007\1\0\1>\1\2\1G\0\1\0\5À\11Update`\0\1\4\3\3\0\13+\1\0\0007\1\0\1+\2\1\0007\2\1\2+\3\2\0>\2\2\2\16\3\0\0>\1\3\1+\1\2\0\16\2\1\0007\1\2\1>\1\2\1G\0\1\0\2À\3À\4À\12Refresh\18getActiveView\13setImage`\0\0\4\3\3\0\13+\0\0\0007\0\0\0+\1\1\0>\0\2\2+\1\2\0007\1\1\1\16\2\0\0>\1\2\2+\2\2\0007\2\2\2\16\3\0\0>\2\2\0E\1\1\0\3À\4À\2À\12getPath\13getImage\18getActiveView3\0\2\6\2\1\0\7+\2\0\0007\2\0\2+\3\1\0\16\4\0\0\16\5\1\0>\2\4\1G\0\1\0\3À\4À\16openNewView2\0\2\5\1\2\0\7+\2\0\0004\3\0\0007\3\1\3\16\4\0\0>\3\2\0029\1\3\2G\0\1\0\7À\ upper\11string·\2\0\1\6\1\13\0007%\1\0\0\16\3\0\0007\2\1\0>\2\2\2\14\0\2\0T\3\5€\16\3\0\0007\2\2\0>\2\2\2\15\0\2\0T\3\3€\16\2\1\0%\3\3\0$\1\3\2\16\3\0\0007\2\4\0>\2\2\2\15\0\2\0T\3\3€\16\2\1\0%\3\5\0$\1\3\2\16\3\0\0007\2\6\0>\2\2\2\15\0\2\0T\3\3€\16\2\1\0%\3\7\0$\1\3\0024\2\8\0004\3\9\0007\3\ \3\16\5\0\0007\4\11\0>\4\2\0=\2\1\3\14\0\2\0T\4\1€G\0\1\0\16\4\1\0\16\5\3\0$\1\5\4+\4\0\0006\4\1\4\15\0\4\0T\5\4€+\4\0\0006\4\1\4>\4\1\1T\4\3€\16\5\0\0007\4\12\0>\4\2\1G\0\1\0\7À\9Skip\15GetKeyCode\9char\11string\ pcall\7S-\14ShiftDown\7M-\12AltDown\7C-\12CmdDown\16ControlDown\5Ó\2\2\1\12\0\13\00134\1\0\0>\1\1\0014\1\1\0007\1\2\1>\1\1\0024\2\3\0>\2\1\0034\4\4\0007\4\5\4\16\5\2\0>\4\2\2\16\2\4\0002\4\3\0\16\5\0\0\16\6\2\0C\7\1\0=\5\1\0<\5\0\0004\5\6\0008\6\1\4\16\7\6\0007\6\7\6>\6\2\0=\5\0\1\19\5\4\0'\6\1\0\1\6\5\0T\5\12€'\5\2\0\19\6\4\0'\7\1\0I\5\8€4\9\8\0006\ \8\4\16\11\ \0007\ \7\ >\ \2\2\16\11\3\0>\9\3\1K\5ø\1274\2\9\0007\2\ \2%\3\11\0004\4\1\0007\4\2\4>\4\1\2\31\4\1\4%\5\12\0$\3\5\3>\2\2\1G\0\1\0\14 seconds\ \28operation completed in \ write\7io\13addImage\14towxImage\13setImage\16fromwxImage\ image\13getImage\ clock\7os\19collectgarbage\3€€À™\4\1\0\1\4\0\7\0\0174\1\0\0007\1\1\1>\1\1\2\16\2\1\0007\1\2\1>\1\2\1\16\2\0\0007\1\3\0>\1\2\2\16\2\1\0007\1\4\1%\3\5\0>\1\3\2\16\2\1\0007\1\6\1>\1\2\1G\0\1\0\12Destroy\12wxFrame\16DynamicCast\19GetEventObject\17ExitMainLoop\13wxGetApp\7wxs\0\2\6\0\5\0\0174\2\0\0007\2\1\0024\3\2\0\16\4\1\0\16\5\0\0>\2\4\2\16\3\2\0007\2\3\2>\2\2\0024\3\0\0007\3\4\3\4\2\3\0T\2\2€)\2\1\0T\3\1€)\2\2\0H\2\2\0\9wxOK\14ShowModal\ frame\20wxMessageDialog\7wx'\0\1\4\2\1\0\0054\1\0\0+\2\0\0+\3\1\0>\1\3\1H\0\2\0\0À\1À\12message\20\1\2\3\0\1\0\0031\2\0\0000\0\0€H\2\2\0\0<\0\1\3\0\3\0\ 4\1\0\0007\1\1\0014\2\0\0:\0\1\0024\2\2\0007\2\2\2>\2\1\0014\2\0\0:\1\1\2H\0\2\0\ debug\8img\7_G„\1\0\0\3\0\6\0\0184\0\0\0\16\1\0\0007\0\1\0>\0\2\0014\0\2\0007\0\3\0>\0\1\2\16\1\0\0007\0\4\0)\2\2\0>\0\3\0014\0\2\0007\0\3\0>\0\1\2\16\1\0\0007\0\5\0>\0\2\1G\0\1\0\13MainLoop\25SetExitOnFrameDelete\13wxGetApp\7wx\9Show\ frameù\7\3\0\13\0<\0…\0014\0\0\0%\1\1\0>\0\2\1%\0\2\0004\1\1\0007\1\3\0014\2\1\0007\2\4\0024\3\1\0007\3\5\3%\4\6\0004\5\1\0007\5\7\0054\6\1\0007\6\8\6'\7\0\2'\8$\2>\6\3\0024\7\1\0007\7\9\7>\1\7\0025\1\ \0004\1\1\0007\1\11\1>\1\1\0025\1\12\0004\1\1\0007\1\13\0011\2\14\0005\2\15\0004\2\0\0%\3\16\0>\2\2\0024\3\0\0%\4\17\0>\3\2\0027\4\18\0034\5\ \0004\6\1\0007\6\5\6>\4\3\0024\5\19\0007\5\20\5>\5\1\2\16\7\5\0007\6\21\0054\8\ \0>\6\3\0014\6\ \0:\5\22\6\16\7\5\0007\6\23\5\16\8\4\0004\9\19\0007\9\24\9>\9\1\2\16\ \9\0007\9\25\9>\9\2\0=\6\2\0011\6\26\0004\7\ \0\16\8\7\0007\7\27\0074\9\1\0007\9\28\9\16\ \6\0>\7\4\0011\7\29\0005\7\30\0001\7\31\0005\7 \0001\7!\0005\7\"\0002\7\0\0001\8#\0005\8$\0001\8%\0005\8&\0004\8\0\0%\9'\0>\8\2\0025\8'\0001\8(\0005\8)\0001\8*\0001\9+\0005\9,\0001\9-\0005\9.\0001\9/\0005\0090\0004\9\ \0\16\ \9\0007\9\27\0094\11\1\0007\0111\11\16\12\8\0>\9\4\0014\9\ \0\16\ \9\0007\0092\0094\11\12\0>\9\3\0014\9\0\0%\ 3\0>\9\2\0014\9\0\0%\ 4\0>\9\2\0014\0095\0%\ 6\0>\9\2\0011\0097\0005\0098\0003\0099\0:\0:\0094\ 8\0:\ 8\0094\ )\0:\ )\0094\ $\0:\ $\0094\ ;\0:\ ;\0094\ ,\0:\ ,\0094\ .\0:\ .\0094\ 0\0:\ 0\0090\0\0€H\9\2\0\14imageMenu\12VERSION\1\0\0\ start\0\15splash.jpg\14loadImage\16menuCreator\13fileMenu\15SetMenuBar\23wxEVT_CLOSE_WINDOW\15imageDebug\0\17imageMessage\0\12message\0\0\17processImage\0\ image\17handleHotkey\0\14setHotkey\0\13addImage\0\13getImage\0\13setImage\0\15wxEVT_SIZE\12Connect\0\15CenterPane\18wxAuiPaneInfo\12AddPane\ uimgr\21SetManagedWindow\17wxAuiManager\ wxaui\8new\14mainpanel\14imageview\ newID\0\17wxID_HIGHEST\12menubar\14wxMenuBar\ frame\26wxDEFAULT_FRAME_STYLE\11wxSize\22wxDefaultPosition\21Image Processing\13wxID_ANY\9NULL\12wxFrame\ 0.0.6\7wx\12require\0" ) package.preload["il.abt"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\2À\1€€€ÿ\3'\0\2\7\0\0\0\8'\2\0\0'\3ÿ\0'\4\1\0I\2\3€6\6\5\0019\6\5\0K\2ý\127G\0\1\0À\2\0\2\12\1\0\3M'\2\0\0'\3\0\0'\4\1\0'\5ÿ\0'\6\1\0I\4\6€6\8\7\1 \8\8\7\30\2\8\0026\8\7\1\30\3\8\3K\4ú\127\9\3\0\0T\4\2€'\4\0\0T\5\3€+\4\0\0!\5\3\2>\4\2\2'\5ÿÿ\4\5\4\0T\0060€Q\6/€'\6\0\0'\3\0\0\16\2\6\0'\6\0\0\21\7\1\4'\8\1\0I\6\6€6\ \9\1 \ \ \9\30\2\ \0026\ \9\1\30\3\ \3K\6ú\127\9\3\0\0T\6\2€\12\6\4\0T\6\3€+\6\0\0!\7\3\2>\6\2\2'\7\0\0'\3\0\0\16\2\7\0\16\7\4\0'\8ÿ\0'\9\1\0I\7\6€6\11\ \1 \11\11\ \30\2\11\0026\11\ \1\30\3\11\3K\7ú\127\9\3\0\0T\7\2€\12\7\4\0T\7\3€+\7\0\0!\8\3\2>\7\2\2\16\5\4\0+\8\0\0\30\9\7\6\23\9\2\9>\8\2\2\16\4\8\0T\6Î\127\1\4\0\0T\6\2€'\6\0\0T\7\1€'\6ÿ\0\16\7\4\0F\6\3\0\3À\0\2\4+\0\2\8\0\0\0\9'\2\0\0'\3\0\0\16\4\0\0'\5\1\0I\3\3€6\7\6\1\30\2\7\2K\3ý\127H\2\2\0ï\23\0\2\31\5\9\3ì\5+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0007\2\1\0007\3\2\0+\4\1\0007\4\3\4\16\5\3\0\16\6\2\0>\4\3\2+\5\1\0007\5\3\5\16\6\3\0\16\7\2\0>\5\3\0022\6\0\0002\7\0\0'\8\0\0'\9ÿ\0'\ \1\0I\8\5€'\12\0\0'\13\0\0009\13\11\0079\12\11\6K\8û\127\24\8\0\1\9\8\1\0T\8\1€\20\1\2\1+\8\2\0\23\9\0\1>\8\2\2'\9\0\0\21\ \2\1'\11\1\0I\9\15€'\13\0\0\21\14\2\1'\15\1\0I\13\ €\16\18\0\0007\17\4\0\16\19\12\0\16\20\16\0>\17\4\0027\17\5\0176\18\17\6\20\18\2\0189\18\17\6K\13ö\127K\9ñ\127'\9\0\0\21\ \2\8'\11\1\0I\0097€'\13\0\0\21\14\2\8'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127K\9É\127\16\9\8\0007\ \2\0\31\ \8\ \21\ \2\ '\11\1\0I\9U€'\13\0\0\21\14\2\8'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127\31\13\8\12\30\14\8\12\20\14\2\0147\15\2\0\3\15\14\0T\15\1€T\9\24€'\15\0\0\21\16\2\1'\17\1\0I\15\19€\16\20\0\0007\19\4\0\16\21\18\0\16\22\13\0>\19\4\0027\19\5\0196\20\19\6\21\20\2\0209\20\19\6\16\21\0\0007\20\4\0\16\22\18\0\16\23\14\0>\20\4\0027\19\5\0206\20\19\6\20\20\2\0209\20\19\6K\15í\127K\9«\1277\9\2\0\31\9\8\0097\ \2\0\21\ \2\ '\11\1\0I\0097€'\13\0\0\21\14\2\8'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127K\9É\127'\9\0\0\21\ \2\1'\11\1\0I\9\15€'\13\0\0\21\14\2\1'\15\1\0I\13\ €\16\18\0\0007\17\4\0\16\19\12\0\16\20\16\0>\17\4\0027\17\5\0176\18\17\7\20\18\2\0189\18\17\7K\13ö\127K\9ñ\127\16\9\8\0007\ \1\0\31\ \8\ \21\ \2\ '\11\1\0I\9è€+\13\4\0\16\14\6\0\16\15\7\0>\13\3\1'\13\0\0\21\14\2\8'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\12\0\16\21\16\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\12\0\16\22\16\0>\19\4\2\16\21\4\0007\20\4\4\16\22\12\0\16\23\16\0>\20\4\2\16\22\4\0007\21\4\4\16\23\12\0\16\24\16\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\12\0\16\22\16\0>\19\4\2\16\21\5\0007\20\4\5\16\22\12\0\16\23\16\0>\20\4\2\16\22\5\0007\21\4\5\16\23\12\0\16\24\16\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127\16\13\8\0007\14\2\0\31\14\8\14\21\14\2\14'\15\1\0I\13Q€+\17\3\0\16\19\0\0007\18\4\0\16\20\12\0\16\21\16\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\12\0\16\22\16\0>\19\4\2\16\21\4\0007\20\4\4\16\22\12\0\16\23\16\0>\20\4\2\16\22\4\0007\21\4\4\16\23\12\0\16\24\16\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\12\0\16\22\16\0>\19\4\2\16\21\5\0007\20\4\5\16\22\12\0\16\23\16\0>\20\4\2\16\22\5\0007\21\4\5\16\23\12\0\16\24\16\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19\31\19\8\16\30\20\8\16\20\20\2\0207\21\2\0\3\21\20\0T\21\1€T\13\25€\30\21\8\12\31\22\8\12\21\23\2\21'\24\1\0I\22\19€\16\27\0\0007\26\4\0\16\28\25\0\16\29\19\0>\26\4\0027\26\5\0266\27\26\6\21\27\2\0279\27\26\6\16\28\0\0007\27\4\0\16\29\25\0\16\30\20\0>\27\4\0027\26\5\0276\27\26\6\20\27\2\0279\27\26\6K\22í\127K\13¯\1277\13\2\0\31\13\8\0137\14\2\0\21\14\2\14'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\12\0\16\21\16\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\12\0\16\22\16\0>\19\4\2\16\21\4\0007\20\4\4\16\22\12\0\16\23\16\0>\20\4\2\16\22\4\0007\21\4\4\16\23\12\0\16\24\16\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\12\0\16\22\16\0>\19\4\2\16\21\5\0007\20\4\5\16\22\12\0\16\23\16\0>\20\4\2\16\22\5\0007\21\4\5\16\23\12\0\16\24\16\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127\31\13\8\12\30\14\8\12\20\14\2\0147\15\1\0\3\15\14\0T\15\1€T\9\24€'\15\0\0\21\16\2\1'\17\1\0I\15\19€\16\20\0\0007\19\4\0\16\21\13\0\16\22\18\0>\19\4\0027\19\5\0196\20\19\7\21\20\2\0209\20\19\7\16\21\0\0007\20\4\0\16\22\14\0\16\23\18\0>\20\4\0027\19\5\0206\20\19\7\20\20\2\0209\20\19\7K\15í\127K\9\24\127+\9\4\0\16\ \6\0\16\11\7\0>\9\3\1'\9\0\0\21\ \2\8'\11\1\0I\0099€7\13\1\0\31\13\8\0137\14\1\0\21\14\2\14'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127K\9Ç\127\16\9\8\0007\ \2\0\31\ \8\ \21\ \2\ '\11\1\0I\9Y€7\13\1\0\31\13\8\0137\14\1\0\21\14\2\14'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127\31\13\8\12\30\14\8\12\20\14\2\0147\15\2\0\3\15\14\0T\15\1€T\9\26€7\15\1\0\31\15\1\0157\16\1\0\21\16\2\16'\17\1\0I\15\19€\16\20\0\0007\19\4\0\16\21\18\0\16\22\13\0>\19\4\0027\19\5\0196\20\19\6\21\20\2\0209\20\19\6\16\21\0\0007\20\4\0\16\22\18\0\16\23\14\0>\20\4\0027\19\5\0206\20\19\6\20\20\2\0209\20\19\6K\15í\127K\9§\1277\9\2\0\31\9\8\0097\ \2\0\21\ \2\ '\11\1\0I\0099€7\13\1\0\31\13\8\0137\14\1\0\21\14\2\14'\15\1\0I\0132€+\17\3\0\16\19\0\0007\18\4\0\16\20\16\0\16\21\12\0>\18\4\0027\18\5\18\16\19\6\0>\17\3\3\16\20\4\0007\19\4\4\16\21\16\0\16\22\12\0>\19\4\2\16\21\4\0007\20\4\4\16\22\16\0\16\23\12\0>\20\4\2\16\22\4\0007\21\4\4\16\23\16\0\16\24\12\0>\21\4\2\16\22\17\0\16\23\17\0:\17\8\21:\23\7\20:\22\6\19\16\20\5\0007\19\4\5\16\21\16\0\16\22\12\0>\19\4\2\16\21\5\0007\20\4\5\16\22\16\0\16\23\12\0>\20\4\2\16\22\5\0007\21\4\5\16\23\16\0\16\24\12\0>\21\4\2\16\22\18\0\16\23\18\0:\18\8\21:\23\7\20:\22\6\19K\13Î\127K\9Ç\127\16\9\4\0\16\ \5\0F\9\3\0\1À\0À\2À\5À\4À\6b\6g\6r\6y\7at\9flat\ width\11height\17GetIntensity\4\0\2‡\1\3\0\9\0\12\0\0174\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\0021\3\5\0001\4\6\0001\5\7\0001\6\8\0001\7\9\0003\8\ \0:\7\11\0080\0\0€H\8\2\0\22adaptiveThreshold\1\0\0\0\0\0\0\0\ floor\9math\13il.color\ image\12require\0" ) package.preload["il.ahe"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\2À\1€€€ÿ\3'\0\2\7\0\0\0\8'\2\0\0'\3ÿ\0'\4\1\0I\2\3€6\6\5\0019\6\5\0K\2ý\127G\0\1\0+\0\2\8\0\0\0\9'\2\0\0'\3\0\0\16\4\0\0'\5\1\0I\3\3€6\7\6\1\30\2\7\2K\3ý\127H\2\2\0—\1\0\2\ \1\0\1#'\2\0\0'\3ÿ\0'\4\0\0'\5ÿ\0'\6\1\0I\4\7€6\8\7\1'\9\0\0\1\9\8\0T\8\2€\16\2\7\0T\4\1€K\4ù\127'\4ÿ\0\16\5\2\0'\6ÿÿI\4\7€6\8\7\1'\9\0\0\1\9\8\0T\8\2€\16\3\7\0T\4\1€K\4ù\127\5\2\3\0T\4\2€'\4\0\0T\5\6€+\4\0\0\31\5\2\0\27\5\0\5\31\6\2\3!\5\6\5>\4\2\2H\4\2\0\3Àþ\3ó\14\0\3\29\5\7\4Í\3'\3\3\0\1\1\3\0T\3\1€H\0\2\0\24\3\0\1\9\3\1\0T\3\3€\20\3\2\1\12\1\3\0T\4\0€+\3\0\0\23\4\0\1>\3\2\2\15\0\2\0T\4\3€+\4\1\0\14\0\4\0T\5\1€+\4\2\0\15\0\2\0T\5\2€'\5\1\0T\6\2€ \5\1\1\28\5\3\5+\6\3\0007\6\0\6\16\7\0\0>\6\2\2\16\0\6\0\16\7\0\0007\6\1\0>\6\2\0022\7\0\0002\8\0\0'\9\0\0'\ ÿ\0'\11\1\0I\9\5€'\13\0\0'\14\0\0009\14\12\0089\13\12\7K\9û\127'\9\0\0\21\ \2\1'\11\1\0I\9\15€'\13\0\0\21\14\2\1'\15\1\0I\13\ €\16\18\0\0007\17\2\0\16\19\12\0\16\20\16\0>\17\4\0027\17\3\0176\18\17\7\20\18\2\0189\18\17\7K\13ö\127K\9ñ\127'\9\0\0\21\ \2\3'\11\1\0I\9\22€'\13\0\0\21\14\2\3'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127K\9ê\127\16\9\3\0007\ \4\0\31\ \3\ \21\ \2\ '\11\1\0I\0094€'\13\0\0\21\14\2\3'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127\31\13\3\12\30\14\3\12\20\14\2\0147\15\4\0\3\15\14\0T\15\1€T\9\24€'\15\0\0\21\16\2\1'\17\1\0I\15\19€\16\20\0\0007\19\2\0\16\21\18\0\16\22\13\0>\19\4\0027\19\3\0196\20\19\7\21\20\2\0209\20\19\7\16\21\0\0007\20\2\0\16\22\18\0\16\23\14\0>\20\4\0027\19\3\0206\20\19\7\20\20\2\0209\20\19\7K\15í\127K\9Ì\1277\9\4\0\31\9\3\0097\ \4\0\21\ \2\ '\11\1\0I\9\22€'\13\0\0\21\14\2\3'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127K\9ê\127'\9\0\0\21\ \2\1'\11\1\0I\9\15€'\13\0\0\21\14\2\1'\15\1\0I\13\ €\16\18\0\0007\17\2\0\16\19\12\0\16\20\16\0>\17\4\0027\17\3\0176\18\17\8\20\18\2\0189\18\17\8K\13ö\127K\9ñ\127\16\9\3\0007\ \5\0\31\ \3\ \21\ \2\ '\11\1\0I\9…€+\13\4\0\16\14\7\0\16\15\8\0>\13\3\1'\13\0\0\21\14\2\3'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\12\0\16\20\16\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\12\0\16\22\16\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127\16\13\3\0007\14\4\0\31\14\3\14\21\14\2\14'\15\1\0I\0130€\16\18\6\0007\17\2\6\16\19\12\0\16\20\16\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\12\0\16\22\16\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17\31\17\3\16\30\18\3\16\20\18\2\0187\19\4\0\3\19\18\0T\19\1€T\13\25€\30\19\3\12\31\20\3\12\21\21\2\19'\22\1\0I\20\19€\16\25\0\0007\24\2\0\16\26\23\0\16\27\17\0>\24\4\0027\24\3\0246\25\24\7\21\25\2\0259\25\24\7\16\26\0\0007\25\2\0\16\27\23\0\16\28\18\0>\25\4\0027\24\3\0256\25\24\7\20\25\2\0259\25\24\7K\20í\127K\13Ð\1277\13\4\0\31\13\3\0137\14\4\0\21\14\2\14'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\12\0\16\20\16\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\12\0\16\22\16\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127\31\13\3\12\30\14\3\12\20\14\2\0147\15\5\0\3\15\14\0T\15\1€T\9\24€'\15\0\0\21\16\2\1'\17\1\0I\15\19€\16\20\0\0007\19\2\0\16\21\13\0\16\22\18\0>\19\4\0027\19\3\0196\20\19\8\21\20\2\0209\20\19\8\16\21\0\0007\20\2\0\16\22\14\0\16\23\18\0>\20\4\0027\19\3\0206\20\19\8\20\20\2\0209\20\19\8K\15í\127K\9{\127+\9\4\0\16\ \7\0\16\11\8\0>\9\3\1'\9\0\0\21\ \2\3'\11\1\0I\9\24€7\13\5\0\31\13\3\0137\14\5\0\21\14\2\14'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127K\9è\127\16\9\3\0007\ \4\0\31\ \3\ \21\ \2\ '\11\1\0I\0098€7\13\5\0\31\13\3\0137\14\5\0\21\14\2\14'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127\31\13\3\12\30\14\3\12\20\14\2\0147\15\4\0\3\15\14\0T\15\1€T\9\26€7\15\5\0\31\15\1\0157\16\5\0\21\16\2\16'\17\1\0I\15\19€\16\20\0\0007\19\2\0\16\21\18\0\16\22\13\0>\19\4\0027\19\3\0196\20\19\7\21\20\2\0209\20\19\7\16\21\0\0007\20\2\0\16\22\18\0\16\23\14\0>\20\4\0027\19\3\0206\20\19\7\20\20\2\0209\20\19\7K\15í\127K\9È\1277\9\4\0\31\9\3\0097\ \4\0\21\ \2\ '\11\1\0I\9\24€7\13\5\0\31\13\3\0137\14\5\0\21\14\2\14'\15\1\0I\13\17€\16\18\6\0007\17\2\6\16\19\16\0\16\20\12\0>\17\4\2\16\18\4\0\16\20\0\0007\19\2\0\16\21\16\0\16\22\12\0>\19\4\0027\19\3\19\16\20\7\0>\18\3\2 \18\5\18:\18\3\17K\13ï\127K\9è\127+\9\3\0007\9\6\9\16\ \6\0@\9\2\0\2À\6À\5À\1À\4À\12YIQ2RGB\11height\ width\6y\7at\ clone\12RGB2YIQ\4\0\2þ\3\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\2\0@\2\4\0\7À§\1\3\0\ \0\14\0\0194\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\0021\3\5\0001\4\6\0001\5\7\0001\6\8\0001\7\9\0001\8\ \0003\9\11\0:\7\12\9:\8\13\0090\0\0€H\9\2\0\28adaptiveContrastStretch\21adaptiveEqualize\1\0\0\0\0\0\0\0\0\ floor\9math\13il.color\ image\12require\0" ) package.preload["il.arith"] = load( "\27LJ\1\2þ\1\0\2\20\3\6\0014+\2\0\0007\3\0\0007\4\0\1>\2\3\2+\3\0\0007\4\1\0007\5\1\1>\3\3\2'\4\3\0+\5\1\0007\5\2\5\16\6\3\0\16\7\2\0>\5\3\2'\6\0\0\21\7\0\4'\8\1\0I\6!€\16\11\5\0007\ \3\5>\ \2\4T\13\26€\16\16\0\0007\15\4\0\16\17\13\0\16\18\14\0>\15\4\0027\15\5\0156\15\9\15\16\17\1\0007\16\4\1\16\18\13\0\16\19\14\0>\16\4\0027\16\5\0166\16\9\16\31\15\16\15\16\17\5\0007\16\4\5\16\18\13\0\16\19\14\0>\16\4\0027\16\5\16+\17\2\0\16\18\15\0'\19\0\0>\17\3\0029\17\9\16A\13\3\3N\13ä\127K\6ß\127H\5\2\0\2À\0À\1À\8rgb\7at\11pixels\9flat\ width\11height\2ü\1\0\2\20\2\6\0014+\2\0\0007\3\0\0007\4\0\1>\2\3\2+\3\0\0007\4\1\0007\5\1\1>\3\3\2'\4\3\0+\5\1\0007\5\2\5\16\6\3\0\16\7\2\0>\5\3\2'\6\0\0\21\7\0\4'\8\1\0I\6!€\16\11\5\0007\ \3\5>\ \2\4T\13\26€\16\16\0\0007\15\4\0\16\17\13\0\16\18\14\0>\15\4\0027\15\5\0156\15\9\15\16\17\1\0007\16\4\1\16\18\13\0\16\19\14\0>\16\4\0027\16\5\0166\16\9\16\30\15\16\15\16\17\5\0007\16\4\5\16\18\13\0\16\19\14\0>\16\4\0027\16\5\16+\17\0\0\16\18\15\0'\19ÿ\0>\17\3\0029\17\9\16A\13\3\3N\13ä\127K\6ß\127H\5\2\0\2À\0À\8rgb\7at\11pixels\9flat\ width\11height\2g\3\0\6\0\ \0\0144\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0014\2\2\0007\2\4\0021\3\5\0001\4\6\0003\5\7\0:\3\8\5:\4\9\0050\0\0€H\5\2\0\8add\8sub\1\0\0\0\0\8min\8max\9math\ image\12require\0" ) package.preload["il.color"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\2À\1€€€ÿ\3ï\1\0\3\ \1\0\13\29\27\3\0\0\27\4\1\1\30\3\4\3\27\4\2\2\30\3\4\3\27\4\3\0\27\5\4\1\31\4\5\4\27\5\5\2\31\4\5\4\27\5\6\0\27\6\7\1\31\5\6\5\27\6\8\2\30\5\6\5\20\6\9\4\22\4\ \6\20\6\11\5\22\5\12\6+\6\0\0\16\7\3\0>\6\2\2+\7\0\0\16\8\4\0>\7\2\2+\8\0\0\16\9\5\0>\8\2\0E\6\2\0\0\0“†‚Ö\28ÐÅÌþ\3ÅÁÀ•\7´‘‹ÿ\3“Ûóû\19šÞôý\3¿¿êø\18ÿ\3µæÌ™\19™³Æþ\3˘ˆØ\18ÖÒþ\3“†‚Ö\28ÐŬþ\3ÇìÎï\15êø‚ÿ\3ƒÖœ´\17ìÎÏþ\3°\2óµ¨Þ\6”¯«ÿ\3Œ\2ᚦ¤\15 å¹ÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixelsÁ\2\0\3\11\3\0\ 8\22\3\0\1\21\1\1\3\22\3\2\2\21\2\3\3\27\3\4\1\30\3\3\0\27\4\5\2\30\3\4\3\27\4\6\1\31\4\4\0\27\5\7\2\31\4\5\4\27\5\8\1\31\5\5\0\27\6\9\2\30\5\6\5+\6\0\0\16\7\3\0'\8\0\0>\6\3\2+\7\0\0\16\8\4\0'\9\0\0>\7\3\2+\8\0\0\16\9\5\0'\ \0\0>\8\3\2\16\5\8\0\16\4\7\0\16\3\6\0+\6\1\0\16\7\3\0'\8ÿ\0>\6\3\2+\7\1\0\16\8\4\0'\9ÿ\0>\7\3\2+\8\1\0\16\9\5\0'\ ÿ\0>\8\3\2\16\5\8\0\16\4\7\0\16\3\6\0+\6\2\0\16\7\3\0>\6\2\2+\7\2\0\16\8\4\0>\7\2\2+\8\2\0\16\9\5\0>\8\2\0E\6\2\0\0\0\1\0\2\0§Ì˜±\2“¦Ìÿ\3°\2£Ã†\26СÃÿ\3Œ\2Éíùý\9¯ºÿ\3ÙòÐÅ\12»¾ÿ\3¹’†‚\22òÐÅþ\3‰ƒ\11¹è’ÿ\3‡‚Öœ\20ÅìÆÿ\3»“±\16•‡íÿ\3,\1\1\4\3\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0À\1À\3À\0\14mapPixels¯\1\0\3\ \1\0\9\23\27\3\0\0\27\4\1\1\30\3\4\3\27\4\2\2\30\3\4\3\31\4\3\2\27\4\3\4\31\5\3\0\27\5\4\5\20\6\5\4\22\4\6\6\20\6\7\5\22\5\8\6+\6\0\0\16\7\3\0>\6\2\2+\7\0\0\16\8\4\0>\7\2\2+\8\0\0\16\9\5\0>\8\2\0E\6\2\0\0\0“†‚Ö\28ÐÅÌþ\3ÅÁÀ•\7´‘‹ÿ\3“Ûóû\19šÞôý\3áÊÖ\18íùýþ\3ÕÆ—Ý\9â °ÿ\3à\1Ýí¶Û\13ÛíÈÿ\3º\2ï†Ø\4½ù§ÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixels\2\0\3\11\3\0\0084\22\3\0\1\21\1\1\3\22\3\2\2\21\2\3\3\27\3\4\2\30\3\3\0\27\4\5\1\31\4\4\0\27\5\6\2\31\4\5\4\27\5\7\1\30\5\5\0+\6\0\0\16\7\3\0'\8\0\0>\6\3\2+\7\0\0\16\8\4\0'\9\0\0>\7\3\2+\8\0\0\16\9\5\0'\ \0\0>\8\3\2\16\5\8\0\16\4\7\0\16\3\6\0+\6\1\0\16\7\3\0'\8ÿ\0>\6\3\2+\7\1\0\16\8\4\0'\9ÿ\0>\7\3\2+\8\1\0\16\9\5\0'\ ÿ\0>\8\3\2\16\5\8\0\16\4\7\0\16\3\6\0+\6\2\0\16\7\3\0>\6\2\2+\7\2\0\16\8\4\0>\7\2\2+\8\2\0\16\9\5\0>\8\2\0E\6\2\0\0\0\1\0\2\0¹ðàÁ\3œ¸°ÿ\3à\1éΝ»\22³çÎÿ\3º\2û¨¸½\20ðúÈÿ\3‘…×Ç\2®åþ\3Éíùý\9¯Šÿ\3њÞô\6‰ƒ€\4,\1\1\4\3\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0À\1À\3À\0\14mapPixels\2\0\3\14\6\0\0049\30\3\1\0\30\3\2\3\23\4\0\3\5\0\1\0T\5\6€\5\1\2\0T\5\4€\16\5\4\0'\6\0\0'\7\0\0F\5\4\0!\5\3\0!\6\3\1!\2\3\2\16\1\6\0\16\0\5\0\31\5\1\0\31\6\2\0\31\7\2\1+\8\0\0\30\9\6\5\27\9\1\9+\ \1\0 \11\5\5 \12\7\6\30\11\12\11>\ \2\2!\9\ \9>\8\2\2\1\1\2\0T\9\6€+\9\2\0\31\9\8\9+\ \3\0 \9\ \9\12\8\9\0T\ \2€+\9\3\0 \8\9\8+\9\4\0\16\ \0\0\16\11\1\0\16\12\2\0>\9\4\2\27\9\0\9\26\9\2\9\22\9\3\9+\ \5\0\16\11\4\0>\ \2\2+\11\5\0\16\12\8\0>\11\2\2+\12\5\0\16\13\9\0>\12\2\0E\ \2\0\1À\2À\3À\4À\0\0\1\0\6\1€€€ÿ\3\2þ\3_\1\1\8\2\6\2\0134\1\0\0007\1\1\0014\2\0\0007\2\2\0024\3\0\0007\3\3\3\27\3\0\3\28\4\1\3\16\6\0\0007\5\4\0001\7\5\0000\0\0€@\5\3\0\1À\3À\0\14mapPixels\7pi\9sqrt\9acos\9math\4þ\3”\3\0\3\11\8\0\4^'\3\0\0'\4\0\0'\5\0\0+\6\0\0 \1\6\1\23\2\0\2+\6\1\0\23\6\1\6\1\1\6\0T\6\17€\26\6\2\2 \5\6\0+\6\2\0\16\7\1\0>\6\2\2 \6\6\2+\7\2\0+\8\3\0\31\8\1\8>\7\2\2!\6\7\6\25\6\2\6 \3\6\0\27\6\1\0\30\7\5\3\31\4\7\6T\6*€+\6\1\0\27\6\3\6\23\6\1\6\1\1\6\0T\6\19€+\6\4\0\31\1\6\1\26\6\2\2 \3\6\0+\6\2\0\16\7\1\0>\6\2\2 \6\6\2+\7\2\0+\8\3\0\31\8\1\8>\7\2\2!\6\7\6\25\6\2\6 \4\6\0\27\6\1\0\30\7\4\3\31\5\7\6T\6\18€+\6\5\0\31\1\6\1\26\6\2\2 \4\6\0+\6\2\0\16\7\1\0>\6\2\2 \6\6\2+\7\2\0+\8\3\0\31\8\1\8>\7\2\2!\6\7\6\25\6\2\6 \5\6\0\27\6\1\0\30\7\5\4\31\3\7\6+\6\6\0\16\7\3\0'\8ÿ\0>\6\3\2+\7\6\0\16\8\4\0'\9ÿ\0>\7\3\2+\8\6\0\16\9\5\0'\ ÿ\0>\8\3\2\16\5\8\0\16\4\7\0\16\3\6\0+\6\7\0\16\7\3\0>\6\2\2+\7\7\0\16\8\4\0>\7\2\2+\8\7\0\16\9\5\0>\8\2\0E\6\2\0\3À\2À\1À\4À\5À\6À\0\0\1\0þ\3\6\2\4\127\1\1\ \2\5\4\0224\1\0\0007\1\1\0014\2\0\0007\2\2\2\27\2\0\2\23\3\1\0024\4\0\0007\4\2\4\23\4\2\0044\5\0\0007\5\2\5\22\5\0\5\23\5\2\0054\6\0\0007\6\2\6\22\6\3\6\23\6\2\6\16\8\0\0007\7\3\0001\9\4\0000\0\0€@\7\3\0\1À\3À\0\14mapPixels\7pi\8cos\9math\4þ\3\6\8\23\0\3\6\0\0\0\4\16\3\0\0\16\4\0\0\16\5\0\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\1\0\16\4\1\0\16\5\1\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\2\0\16\4\2\0\16\5\2\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixelsc\0\3\8\1\0\3\15\27\3\0\0\27\4\1\1\30\3\4\3\27\4\2\2\30\3\4\3+\4\0\0\16\5\3\0>\4\2\2+\5\0\0\16\6\3\0>\5\2\2+\6\0\0\16\7\3\0>\6\2\0E\4\2\0\0\0“†‚Ö\28ÐÅÌþ\3ÅÁÀ•\7´‘‹ÿ\3“Ûóû\19šÞôý\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixelsw\0\3\8\1\0\5\17\27\3\0\0\27\4\1\1\31\3\4\3\27\4\2\2\31\3\4\3\20\4\3\3\22\3\4\4+\4\0\0\16\5\3\0>\4\2\2+\5\0\0\16\6\3\0>\5\2\2+\6\0\0\16\7\3\0>\6\2\0E\4\2\0\0\0¿¿êø\18ÿ\3µæÌ™\19™³Æþ\3˘ˆØ\18ÖÒþ\3°\2óµ¨Þ\6”¯«ÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixelsw\0\3\8\1\0\5\17\27\3\0\0\27\4\1\1\31\3\4\3\27\4\2\2\30\3\4\3\20\4\3\3\22\3\4\4+\4\0\0\16\5\3\0>\4\2\2+\5\0\0\16\6\3\0>\5\2\2+\6\0\0\16\7\3\0>\6\2\0E\4\2\0\0\0“†‚Ö\28ÐŬþ\3ÇìÎï\15êø‚ÿ\3ƒÖœ´\17ìÎÏþ\3Œ\2ᚦ¤\15 å¹ÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixelsw\0\3\8\1\0\5\17\27\3\0\0\27\4\1\1\31\3\4\3\27\4\2\2\30\3\4\3\20\4\3\3\22\3\4\4+\4\0\0\16\5\3\0>\4\2\2+\5\0\0\16\6\3\0>\5\2\2+\6\0\0\16\7\3\0>\6\2\0E\4\2\0\0\0奈„\12塋þ\11ËÖ²\27ùýÉþ\3ƒÖœ´\17ìÎïþ\3à\1Ýí¶Û\13ÛíÈÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixelsk\0\3\7\1\0\5\14\27\3\0\0\27\4\1\1\31\3\4\3\27\4\2\2\31\3\4\3+\4\0\0\20\5\3\3\22\5\4\5>\4\2\2\16\3\4\0\16\4\3\0\16\5\3\0\16\6\3\0F\4\4\0\0\0ݞŠ®\15”ÜŽÿ\3÷Ñðú\8áõÿ\3µæÌ™\19™³æý\3º\2ï†Ø\4½ù§ÿ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixels.\0\3\7\1\0\1\9+\3\0\0\30\4\1\0\30\4\2\4\23\4\0\4>\3\2\2\16\4\3\0\16\5\3\0\16\6\3\0F\4\4\0\0\0\6(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\3À\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\1\0\16\4\1\0\16\5\1\0F\3\4\0008\1\1\4\1\2\0\9+\1\0\0\16\2\0\0>\1\2\2\16\0\1\0\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\8À\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\2\0\16\4\2\0\16\5\2\0F\3\4\0008\1\1\4\1\2\0\9+\1\0\0\16\2\0\0>\1\2\2\16\0\1\0\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\8À\0\14mapPixels7\0\2\4\2\1\0\ \7\1\0\0T\2\4€+\2\0\0\16\3\0\0@\2\2\0T\2\3€+\2\1\0\16\3\0\0@\2\2\0G\0\1\0\18À\13À\8ihs\23\0\3\6\0\0\0\4\16\3\0\0\16\4\2\0\16\5\1\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\1\0\16\4\0\0\16\5\2\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\1\0\16\4\2\0\16\5\0\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\2\0\16\4\0\0\16\5\1\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels\23\0\3\6\0\0\0\4\16\3\2\0\16\4\1\0\16\5\0\0F\3\4\0&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixels€\3\0\4\17\2\ \1R+\4\0\0007\5\0\0017\6\0\0027\7\0\3>\4\4\2+\5\0\0007\6\1\0017\7\1\0027\8\1\3>\5\4\0024\6\2\0007\6\3\6\16\7\5\0\16\8\4\0>\6\3\2\16\8\6\0007\7\4\6>\7\2\4T\ <€\16\13\1\0007\12\5\1\16\14\ \0\16\15\11\0>\12\4\0027\12\6\12\16\14\6\0007\13\5\6\16\15\ \0\16\16\11\0>\13\4\2+\14\1\0008\15\0\0128\16\1\12\30\15\16\0158\16\2\12\30\15\16\15\23\15\0\15>\14\2\2:\14\7\13\16\14\2\0007\13\5\2\16\15\ \0\16\16\11\0>\13\4\0027\12\6\13\16\14\6\0007\13\5\6\16\15\ \0\16\16\11\0>\13\4\2+\14\1\0008\15\0\0128\16\1\12\30\15\16\0158\16\2\12\30\15\16\15\23\15\0\15>\14\2\2:\14\8\13\16\14\3\0007\13\5\3\16\15\ \0\16\16\11\0>\13\4\0027\12\6\13\16\14\6\0007\13\5\6\16\15\ \0\16\16\11\0>\13\4\2+\14\1\0008\15\0\0128\16\1\12\30\15\16\0158\16\2\12\30\15\16\15\23\15\0\15>\14\2\2:\14\9\13A\ \3\3N\ Â\127H\6\2\0\1À\3À\6b\6g\6r\8rgb\7at\11pixels\9flat\ image\ width\11height\6×\4\3\0\29\0B\0F4\0\0\0007\0\1\0004\1\0\0007\1\2\0014\2\0\0007\2\3\0021\3\4\0001\4\5\0001\5\6\0001\6\7\0001\7\8\0001\8\9\0001\9\ \0001\ \11\0001\11\12\0001\12\13\0001\13\14\0001\14\15\0001\15\16\0001\16\17\0001\17\18\0001\18\19\0001\19\20\0001\20\21\0001\21\22\0001\22\23\0001\23\24\0001\24\25\0001\25\26\0001\26\27\0001\27\28\0003\28\29\0:\4\30\28:\5\31\28:\6 \28:\7!\28:\8\"\28:\9#\28:\ $\28:\11%\28:\12&\28:\13'\28:\14(\28:\15)\28:\16*\28:\17+\28:\18,\28:\19-\28:\20.\28:\21/\28:\ 0\28:\0111\28:\0122\28:\0133\28:\0144\28:\0155\28:\0166\28:\0177\28:\0188\28:\0199\28:\20:\28:\21;\28:\22<\28:\23=\28:\24>\28:\25?\28:\26@\28:\27A\0280\0\0€H\28\2\0\15falseColor\12RGB2BGR\12RGB2BRG\12RGB2GBR\12RGB2GRB\12RGB2RBG\17GetIntensity\9GetS\9GetH\9GetI\9GetV\9GetU\18GetQuadrature\15GetInphase\9GetY\9GetB\9GetG\9GetR\17getIntensity\9getS\9getH\9getI\9getV\9getU\18getQuadrature\15getInphase\9getY\9getB\9getG\9getR\12IHS2RGB\12RGB2IHS\12YUV2RGB\12RGB2YUV\12YIQ2RGB\12RGB2YIQ\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ floor\8min\8max\9math\0" ) package.preload["il.edge"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\6À\1€€€ÿ\3'\0\1\5\2\0\0\7+\1\0\0+\2\1\0\16\3\0\0'\4\0\0>\2\3\2'\3ÿ\0@\1\3\0\4À\3Àü\4\0\1\16\4\8\2\0017\1\0\0007\2\1\0+\3\0\0007\3\2\3\16\4\2\0\16\5\1\0>\3\3\2+\4\1\0007\4\3\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\4\0'\6\1\0>\4\3\4T\7e€\16\ \0\0007\9\5\0\21\11\0\7\21\12\0\8>\9\4\0027\9\6\9\16\11\0\0007\ \5\0\21\12\0\7\16\13\8\0>\ \4\0027\ \6\ \27\ \1\ \30\9\ \9\16\11\0\0007\ \5\0\21\12\0\7\20\13\0\8>\ \4\0027\ \6\ \30\9\ \9\16\11\0\0007\ \5\0\20\12\0\7\21\13\0\8>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\20\13\0\7\16\14\8\0>\11\4\0027\11\6\11\27\11\1\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\7\20\14\0\8>\11\4\0027\11\6\11\30\ \11\ \31\9\ \9\16\11\0\0007\ \5\0\21\12\0\7\21\13\0\8>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\16\13\7\0\21\14\0\8>\11\4\0027\11\6\11\27\11\1\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\7\21\14\0\8>\11\4\0027\11\6\11\30\ \11\ \16\12\0\0007\11\5\0\21\13\0\7\20\14\0\8>\11\4\0027\11\6\11\16\13\0\0007\12\5\0\16\14\7\0\20\15\0\8>\12\4\0027\12\6\12\27\12\1\12\30\11\12\11\16\13\0\0007\12\5\0\20\14\0\7\20\15\0\8>\12\4\0027\12\6\12\30\11\12\11\31\ \11\ +\11\2\0 \12\9\9 \13\ \ \30\12\13\12>\11\2\2\16\13\3\0007\12\5\3\16\14\7\0\16\15\8\0>\12\4\2+\13\3\0\16\14\11\0'\15ÿ\0>\13\3\2:\13\6\12A\7\3\3N\7™\127\16\5\0\0007\4\4\0'\6\1\0>\4\3\4T\7\12€\16\ \0\0007\9\5\0\16\11\7\0\16\12\8\0>\9\4\2\16\11\3\0007\ \5\3\16\12\7\0\16\13\8\0>\ \4\0027\ \6\ :\ \6\9A\7\3\3N\7ò\127+\4\1\0007\4\7\4\16\5\0\0@\4\2\0\2À\0À\7À\4À\12YIQ2RGB\6y\7at\11pixels\12RGB2YIQ\9flat\ width\11height\2\4ï\4\0\1\20\5\8\4ˆ\0017\1\0\0007\2\1\0+\3\0\0007\3\2\3\16\4\2\0\16\5\1\0>\3\3\2+\4\1\0007\4\3\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\4\0'\6\1\0>\4\3\4T\7t€\16\ \0\0007\9\5\0\21\11\0\7\21\12\0\8>\9\4\0027\9\6\9\16\11\0\0007\ \5\0\21\12\0\7\16\13\8\0>\ \4\0027\ \6\ \27\ \1\ \30\9\ \9\16\11\0\0007\ \5\0\21\12\0\7\20\13\0\8>\ \4\0027\ \6\ \30\9\ \9\16\11\0\0007\ \5\0\20\12\0\7\21\13\0\8>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\20\13\0\7\16\14\8\0>\11\4\0027\11\6\11\27\11\1\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\7\20\14\0\8>\11\4\0027\11\6\11\30\ \11\ \31\9\ \9\16\11\0\0007\ \5\0\21\12\0\7\21\13\0\8>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\16\13\7\0\21\14\0\8>\11\4\0027\11\6\11\27\11\1\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\7\21\14\0\8>\11\4\0027\11\6\11\30\ \11\ \16\12\0\0007\11\5\0\21\13\0\7\20\14\0\8>\11\4\0027\11\6\11\16\13\0\0007\12\5\0\16\14\7\0\20\15\0\8>\12\4\0027\12\6\12\27\12\1\12\30\11\12\11\16\13\0\0007\12\5\0\20\14\0\7\20\15\0\8>\12\4\0027\12\6\12\30\11\12\11\31\ \11\ +\11\2\0\18\12\9\0\16\13\ \0>\11\3\2'\12\0\0\1\11\12\0T\12\4€+\12\3\0\30\12\12\11+\13\3\0\30\11\13\12+\12\4\0+\13\3\0\28\13\2\13 \13\13\11\20\13\3\13>\12\2\2\16\11\12\0'\12\0\0'\13\2\0'\14\1\0I\12\8€\16\17\3\0007\16\5\3\16\18\7\0\16\19\8\0>\16\4\0027\16\7\0169\11\15\16K\12ø\127A\7\3\3N\7Š\127H\3\2\0\2À\0À\9À\ À\6À\8rgb\6y\7at\11pixels\17GetIntensity\9flat\ width\11height\2\4\1€Àÿ‚\4\1€€€ÿ\3Ë\2\0\2\22\4\6\1F+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0\16\3\0\0007\2\1\0>\2\2\2\15\0\1\0T\3\5€+\3\1\0\23\4\0\1>\3\2\2\12\1\3\0T\4\1€'\1\1\0+\3\2\0\16\4\1\0'\5\1\0>\3\3\2\16\1\3\0\16\4\0\0007\3\2\0\16\5\1\0>\3\3\4T\6)€'\8ÿ\0'\9\0\0\18\ \1\0\16\11\1\0'\12\1\0I\ \22€\18\14\1\0\16\15\1\0'\16\1\0I\14\17€\16\19\0\0007\18\3\0\30\20\13\6\30\21\17\7>\18\4\0027\18\4\18+\19\3\0\16\20\8\0\16\21\18\0>\19\3\2\16\8\19\0+\19\2\0\16\20\9\0\16\21\18\0>\19\3\2\16\9\19\0K\14ï\127K\ ê\127'\ \0\0'\11\2\0'\12\1\0I\ \9€\16\15\2\0007\14\3\2\16\16\6\0\16\17\7\0>\14\4\0027\14\5\14\31\15\8\0099\15\13\14K\ ÷\127A\6\3\3N\6Õ\127H\2\2\0\0À\6À\3À\4À\8rgb\6y\7at\11pixels\ clone\17GetIntensity\4í\1\0\1\16\3\6\0-+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0+\1\1\0007\1\1\1\16\2\0\0'\3\1\0>\1\3\2\16\3\0\0007\2\2\0>\2\2\4T\5\28€+\7\2\0\16\9\0\0007\8\3\0\16\ \5\0\16\11\6\0>\8\4\0027\8\4\8\16\ \1\0007\9\3\1\16\11\5\0\16\12\6\0>\9\4\0027\9\4\9\31\8\9\8'\9\0\0>\7\3\2'\8\0\0'\9\2\0'\ \1\0I\8\8€\16\13\0\0007\12\3\0\16\14\5\0\16\15\6\0>\12\4\0027\12\5\0129\7\11\12K\8ø\127A\5\3\3N\5â\127H\0\2\0\0À\1À\3À\8rgb\6y\7at\11pixels\19erodeIntensity\17GetIntensity™\5\0\2\20\4\8\2–\0017\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\3\0\16\6\2\0>\4\3\2+\5\1\0007\5\3\5\16\6\0\0>\5\2\2\16\0\5\0\15\0\1\0T\5C€\16\6\0\0007\5\4\0'\7\1\0>\5\3\4T\8;€\16\11\0\0007\ \5\0\21\12\0\8\21\13\0\9>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\21\13\0\8\16\14\9\0>\11\4\0027\11\6\11\30\ \11\ \16\12\0\0007\11\5\0\21\13\0\8\20\14\0\9>\11\4\0027\11\6\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\8\21\14\0\9>\11\4\0027\11\6\11\16\13\0\0007\12\5\0\20\14\0\8\16\15\9\0>\12\4\0027\12\6\12\30\11\12\11\16\13\0\0007\12\5\0\20\14\0\8\20\15\0\9>\12\4\0027\12\6\12\30\11\12\11\31\ \11\ +\11\2\0+\12\3\0\16\13\ \0>\12\2\2'\13ÿ\0>\11\3\2'\12\0\0'\13\2\0'\14\1\0I\12\8€\16\17\4\0007\16\5\4\16\18\8\0\16\19\9\0>\16\4\0027\16\7\0169\11\15\16K\12ø\127A\8\3\3N\8Ã\127T\5D€\16\6\0\0007\5\4\0'\7\1\0>\5\3\4T\8=€\16\11\0\0007\ \5\0\21\12\0\8\21\13\0\9>\ \4\0027\ \6\ \16\12\0\0007\11\5\0\16\13\8\0\21\14\0\9>\11\4\0027\11\6\11\27\11\1\11\30\ \11\ \16\12\0\0007\11\5\0\20\13\0\8\21\14\0\9>\11\4\0027\11\6\11\30\ \11\ \16\12\0\0007\11\5\0\21\13\0\8\20\14\0\9>\11\4\0027\11\6\11\16\13\0\0007\12\5\0\16\14\8\0\20\15\0\9>\12\4\0027\12\6\12\27\12\1\12\30\11\12\11\16\13\0\0007\12\5\0\20\14\0\8\20\15\0\9>\12\4\0027\12\6\12\30\11\12\11\31\ \11\ +\11\2\0+\12\3\0\16\13\ \0>\12\2\2'\13ÿ\0>\11\3\2'\12\0\0'\13\2\0'\14\1\0I\12\8€\16\17\4\0007\16\5\4\16\18\8\0\16\19\9\0>\16\4\0027\16\7\0169\11\15\16K\12ø\127A\8\3\3N\8Á\127H\4\2\0\2À\0À\4À\5À\8rgb\6y\7at\11pixels\17GetIntensity\9flat\ width\11height\2\4\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\2\0@\1\3\0\17À\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\1\0@\1\3\0\17À‡\5\0\2\24\3\7\4‹\1+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0\16\3\0\0007\2\1\0>\2\2\0023\3\2\0'\4\5\0;\4\0\3\16\5\0\0007\4\3\0'\6\1\0>\4\3\4T\7u€2\9\0\0\16\11\0\0007\ \4\0\21\12\0\7\21\13\0\8>\ \4\0027\ \5\ ;\ \0\9\16\11\0\0007\ \4\0\16\12\7\0\21\13\0\8>\ \4\0027\ \5\ ;\ \1\9\16\11\0\0007\ \4\0\20\12\0\7\21\13\0\8>\ \4\0027\ \5\ ;\ \2\9\16\11\0\0007\ \4\0\20\12\0\7\16\13\8\0>\ \4\0027\ \5\ ;\ \3\9\16\11\0\0007\ \4\0\20\12\0\7\20\13\0\8>\ \4\0027\ \5\ ;\ \4\9\16\11\0\0007\ \4\0\16\12\7\0\20\13\0\8>\ \4\0027\ \5\ ;\ \5\9\16\11\0\0007\ \4\0\21\12\0\7\20\13\0\8>\ \4\0027\ \5\ ;\ \6\9\16\11\0\0007\ \4\0\21\12\0\7\16\13\8\0>\ \4\0027\ \5\ ;\ \7\9'\ \0\0'\11\0\0'\12\0\0'\13\0\0'\14\0\0'\15\7\0'\16\1\0I\14\25€'\11\0\0'\18\0\0'\19\7\0'\20\1\0I\18\ €6\22\ \0036\23\21\9 \22\23\22\30\11\22\11\20\ \0\ '\22\7\0\1\22\ \0T\22\1€'\ \0\0K\18ö\127\1\13\11\0T\18\2€\16\13\11\0\16\12\17\0\21\ \0\ '\18\0\0\1\ \18\0T\18\1€'\ \7\0K\14ç\127\15\0\1\0T\14\11€\16\15\2\0007\14\4\2\16\16\7\0\16\17\8\0>\14\4\2+\15\1\0\23\16\1\12\22\16\2\16>\15\2\2:\15\5\14T\14\14€+\14\1\0\23\15\3\13>\14\2\2\16\13\14\0\16\15\2\0007\14\4\2\16\16\7\0\16\17\8\0>\14\4\2+\15\2\0\16\16\13\0'\17ÿ\0>\15\3\2:\15\5\14A\7\3\3N\7‰\127+\4\0\0007\4\6\4\16\5\2\0@\4\2\0\0À\11À\4À\12YIQ2RGB\6y\7at\11pixels\1\8\0\0\3\5\3\5\3ýÿÿÿ\15\3ýÿÿÿ\15\3ýÿÿÿ\15\3ýÿÿÿ\15\3ýÿÿÿ\15\ clone\12RGB2YIQ\2\16þ\3\6\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\1\0@\1\3\0\20À\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\2\0@\1\3\0\20ÀÝ\2\0\2\13\4\6\3J+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0\16\3\0\0007\2\1\0>\2\2\2\16\4\0\0007\3\2\0'\5\1\0>\3\3\4T\0067€\16\9\0\0007\8\3\0\16\ \6\0\16\11\7\0>\8\4\0027\8\4\8\27\8\0\8\16\ \0\0007\9\3\0\16\11\6\0\21\12\1\7>\9\4\0027\9\4\9\31\8\9\8\16\ \0\0007\9\3\0\16\11\6\0\20\12\1\7>\9\4\0027\9\4\9\31\8\9\8\16\ \0\0007\9\3\0\21\11\1\6\16\12\7\0>\9\4\0027\9\4\9\31\8\9\8\16\ \0\0007\9\3\0\20\11\1\6\16\12\7\0>\9\4\0027\9\4\9\31\8\9\8\15\0\1\0T\9\5€+\9\1\0\20\ \2\8>\9\2\2\12\8\9\0T\ \7€+\9\2\0+\ \3\0\16\11\8\0>\ \2\2'\11ÿ\0>\9\3\2\16\8\9\0\16\ \2\0007\9\3\2\16\11\6\0\16\12\7\0>\9\4\2:\8\4\9A\6\3\3N\6Ç\127+\3\0\0007\3\5\3\16\4\2\0@\3\2\0\0À\12À\4À\5À\12YIQ2RGB\6y\7at\11pixels\ clone\12RGB2YIQ\8\2€\2\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\2\0@\1\3\0\23À¶\1\0\3\13\4\0\5%+\3\0\0+\4\1\0'\5\2\0>\4\2\2\27\4\0\4 \4\0\4\20\4\1\4\23\4\2\4>\3\2\2+\4\1\0+\5\2\0\27\5\2\5>\4\2\2 \4\0\4 \4\0\4\28\4\3\4\18\5\3\0\16\6\3\0'\7\1\0I\5\16€ \9\8\8 \ \0\0!\9\ \9\30\ \3\8+\11\3\0\27\12\4\9>\11\2\2 \11\11\0049\11\ \2\30\ \3\8\26\11\3\9\30\12\3\0086\12\12\2 \11\12\0119\11\ \1K\5ð\127G\0\1\0\6À\7À\ À\8À\12ݞŠ®\15”ܾÿ\3\4\2\1€€€ÿ\11Ï\4\0\2\27\6\8\6}7\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\3\0>\4\2\2+\5\1\0+\6\2\0'\7\2\0>\6\2\2\27\6\0\6 \6\1\6\20\6\1\6\23\6\2\6>\5\2\0022\6\0\0002\7\0\0+\8\3\0\16\9\1\0\16\ \6\0\16\11\7\0>\8\4\1\16\9\0\0007\8\4\0>\8\2\4T\11Y€'\13\0\0'\14\0\0'\15\0\0'\16\0\0\18\17\5\0\16\18\5\0'\19\1\0I\0177€+\21\4\0+\22\5\0\30\23\20\12'\24\0\0>\22\3\2\21\23\3\3>\21\3\2+\22\4\0+\23\5\0\30\24\20\11'\25\0\0>\23\3\2\21\24\3\2>\22\3\2\16\24\0\0007\23\5\0\16\25\11\0\16\26\21\0>\23\4\0027\23\6\23\30\24\5\0206\24\24\6 \23\24\23\30\13\23\13\16\24\0\0007\23\5\0\16\25\11\0\16\26\21\0>\23\4\0027\23\6\23\30\24\5\0206\24\24\7 \23\24\23\30\15\23\15\16\24\0\0007\23\5\0\16\25\22\0\16\26\12\0>\23\4\0027\23\6\23\30\24\5\0206\24\24\7 \23\24\23\30\14\23\14\16\24\0\0007\23\5\0\16\25\22\0\16\26\12\0>\23\4\0027\23\6\23\30\24\5\0206\24\24\6 \23\24\23\30\16\23\16K\17É\127 \17\14\13 \18\16\15\30\17\18\17'\18\0\0\1\17\18\0T\18\2€\20\17\4\17T\18\1€\20\17\5\17+\18\4\0+\19\5\0\16\20\17\0'\21\0\0>\19\3\2'\20ÿ\0>\18\3\2\16\17\18\0\16\19\4\0007\18\5\4\16\20\11\0\16\21\12\0>\18\4\2+\19\1\0\16\20\17\0>\19\2\2:\19\6\18A\11\3\3N\11¥\127+\8\0\0007\8\7\8\16\9\4\0@\8\2\0\0À\6À\7À\25À\4À\3À\12YIQ2RGB\6y\7at\11pixels\ clone\12RGB2YIQ\ width\11height\12ݞŠ®\15”ܾÿ\3\4\2\1€Àÿ‚\4\1€ €ƒ\4¢\3\0\1\26\4\8\0Y+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0+\3\1\0007\3\3\3\16\4\2\0\16\5\1\0>\3\3\2'\4\ \0\16\6\0\0007\5\4\0'\7\1\0>\5\3\4T\8D€'\ ÿ\0'\11\0\0'\12ÿÿ'\13\1\0'\14\1\0I\12\26€'\16ÿÿ'\17\1\0'\18\1\0I\16\21€+\20\2\0\16\21\ \0\16\23\0\0007\22\5\0\30\24\15\8\30\25\19\9>\22\4\0027\22\6\22>\20\3\2\16\ \20\0+\20\3\0\16\21\11\0\16\23\0\0007\22\5\0\30\24\15\8\30\25\19\9>\22\4\0027\22\6\22>\20\3\2\16\11\20\0K\16ë\127K\12æ\127'\12€\0\0\11\12\0T\12\6€'\12€\0\0\12\ \0T\12\3€\31\12\ \11\1\12\4\0T\12\14€'\12\0\0'\13\2\0'\14\1\0I\12\9€\16\17\3\0007\16\5\3\16\18\8\0\16\19\9\0>\16\4\0027\16\7\16'\17\0\0009\17\15\16K\12÷\127T\12\13€'\12\0\0'\13\2\0'\14\1\0I\12\9€\16\17\3\0007\16\5\3\16\18\8\0\16\19\9\0>\16\4\0027\16\7\16'\17ÿ\0009\17\15\16K\12÷\127A\8\3\3N\8º\127H\3\2\0\0À\2À\4À\3À\8rgb\6y\7at\11pixels\9flat\ width\11height\17GetIntensity+\0\2\5\2\0\0\8+\2\0\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\1\0\16\3\0\0@\2\2\0\26À\27À¤\4\3\0\30\0000\0>4\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\0\0%\3\3\0>\2\2\0024\3\4\0007\3\5\0034\4\4\0007\4\6\0044\5\4\0007\5\7\0054\6\4\0007\6\8\0064\7\4\0007\7\9\0074\8\4\0007\8\ \0084\9\4\0007\9\11\0094\ \4\0007\ \12\ 1\11\13\0001\12\14\0001\13\15\0001\14\16\0001\15\17\0001\16\18\0001\17\19\0001\18\20\0001\19\21\0001\20\22\0001\21\23\0001\22\24\0001\23\25\0001\24\26\0001\25\27\0001\26\28\0001\27\29\0001\28\30\0003\29\31\0:\13 \29:\14!\29:\17\"\29:\18#\29:\19$\29:\20%\29:\21&\29:\22'\29:\23(\29:\24)\29:\26*\29:\28+\29:\28,\29:\27-\29:\15.\29:\16/\0290\0\0€H\29\2\0\18morphGradient\ range\18zeroCrossings\17marrHildreth\24laplacianGaussianZC\22laplacianGaussian\18laplacianZero\14laplacian\14kirschDir\14kirschMag\17kirschMagDir\17edgeVertical\19edgeHorizontal\15edgeHorVer\13sobelDir\13sobelMag\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7pi\ atan2\8exp\9sqrt\ floor\8abs\8min\8max\9math\ image\13il.morph\13il.color\12require\0" ) package.preload["il.fftdisplay"] = load( "\27LJ\1\2Ü\6\0\1\29\7\7\5Ä\1\14\0\0\0T\1\2€)\1\0\0H\1\2\0+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0+\3\1\0+\4\2\0\16\5\1\0>\4\2\2+\5\2\0'\6\2\0>\5\2\2!\4\5\4>\3\2\2+\4\1\0+\5\2\0\16\6\2\0>\5\2\2+\6\2\0'\7\2\0>\6\2\2!\5\6\5>\4\2\2'\5\2\0#\5\3\5'\6\2\0#\6\4\0062\7\0\0002\8\0\0'\9\0\0\21\ \0\1'\11\1\0I\9/€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\2'\15\1\0I\13\27€6\17\12\7\30\18\16\12\24\18\1\18\9\18\2\0T\18\9€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\14\0\18\0T\19\8€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\18\18\18\0009\18\16\0176\17\12\8'\18\0\0009\18\16\17K\13å\127\16\13\2\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9Ñ\127\16\9\1\0\21\ \0\5'\11\1\0I\9\16€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9ð\127+\9\3\0007\9\5\9'\ \1\0\16\11\7\0\16\12\8\0>\9\4\1'\9\0\0'\ \0\0\21\11\0\5'\12\1\0I\ \20€'\14\0\0\21\15\0\6'\16\1\0I\14\15€6\18\13\0076\18\17\0186\19\13\0086\19\17\19 \20\18\18 \21\19\19\30\20\21\0206\21\13\0079\20\17\21+\21\4\0\16\22\9\0\16\23\20\0>\21\3\2\16\9\21\0K\14ñ\127K\ ì\127(\ \3\0\1\9\ \0T\ \2€'\ \1\0T\11\7€+\ \2\0+\11\5\0\16\12\9\0>\11\2\2\20\11\0\11>\ \2\2\28\ \4\ +\11\6\0007\11\6\11\16\12\6\0\16\13\5\0>\11\3\2'\12\0\0\21\13\0\5'\14\1\0I\12%€'\16\0\0\21\17\0\6'\18\1\0I\16 €6\20\15\0076\20\19\20(\21\3\0\1\20\21\0T\21\2€'\20\0\0T\21\7€+\21\2\0+\22\5\0\16\23\20\0>\22\2\2\20\22\0\22>\21\2\2 \20\21\ '\21ÿ\0\1\21\20\0T\21\2€'\20ÿ\0T\21\0€'\21\0\0'\22\2\0'\23\1\0I\21\8€\16\26\11\0007\25\3\11\16\27\15\0\16\28\19\0>\25\4\0027\25\4\0259\20\24\25K\21ø\127K\16à\127K\12Û\127H\11\2\0\1À\8À\5À\2À\9À\6À\0À\9flat\ fft2D\8rgb\7at\ width\11height\12RGB2YIQ\2\4\0›¶¯‹\20÷Ãõ\3þ\3ò\5\0\1\26\8\7\5ª\1\14\0\0\0T\1\2€)\1\0\0H\1\2\0+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0+\3\1\0+\4\2\0\16\5\1\0>\4\2\2+\5\2\0'\6\2\0>\5\2\2!\4\5\4>\3\2\2+\4\1\0+\5\2\0\16\6\2\0>\5\2\2+\6\2\0'\7\2\0>\6\2\2!\5\6\5>\4\2\2'\5\2\0#\5\3\5'\6\2\0#\6\4\0062\7\0\0002\8\0\0'\9\0\0\21\ \0\1'\11\1\0I\9/€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\2'\15\1\0I\13\27€6\17\12\7\30\18\16\12\24\18\1\18\9\18\2\0T\18\9€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\14\0\18\0T\19\8€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\18\18\18\0009\18\16\0176\17\12\8'\18\0\0009\18\16\17K\13å\127\16\13\2\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9Ñ\127\16\9\1\0\21\ \0\5'\11\1\0I\9\16€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9ð\127+\9\3\0007\9\5\9'\ \1\0\16\11\7\0\16\12\8\0>\9\4\1'\9\0\0\21\ \0\5'\11\1\0I\9\24€'\13\0\0\21\14\0\6'\15\1\0I\13\19€+\17\4\0006\18\12\0086\18\16\0186\19\12\0076\19\16\19>\17\3\2+\18\5\0+\19\6\0\30\19\19\17\22\19\3\19+\20\6\0\27\20\1\20!\19\20\19\20\19\4\19>\18\2\2\16\17\18\0006\18\12\0079\17\16\18K\13í\127K\9è\127+\9\7\0007\9\6\9\16\ \6\0\16\11\5\0>\9\3\2'\ \0\0\21\11\0\5'\12\1\0I\ \20€'\14\0\0\21\15\0\6'\16\1\0I\14\15€'\18\0\0'\19\2\0'\20\1\0I\18\ €\16\23\9\0007\22\3\9\16\24\13\0\16\25\17\0>\22\4\0027\22\4\0226\23\13\0076\23\17\0239\23\21\22K\18ö\127K\14ñ\127K\ ì\127H\9\2\0\1À\8À\5À\2À\4À\7À\3À\0À\9flat\ fft2D\8rgb\7at\ width\11height\12RGB2YIQ\2\4\0þ\3\1€€€ÿ\3†\8\0\1 \11\7\6ë\1\14\0\0\0T\1\2€)\1\0\0H\1\2\0+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0+\3\1\0+\4\2\0\16\5\1\0>\4\2\2+\5\2\0'\6\2\0>\5\2\2!\4\5\4>\3\2\2+\4\1\0+\5\2\0\16\6\2\0>\5\2\2+\6\2\0'\7\2\0>\6\2\2!\5\6\5>\4\2\2'\5\2\0#\5\3\5'\6\2\0#\6\4\0062\7\0\0002\8\0\0'\9\0\0\21\ \0\1'\11\1\0I\9/€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\2'\15\1\0I\13\27€6\17\12\7\30\18\16\12\24\18\1\18\9\18\2\0T\18\9€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\14\0\18\0T\19\8€\16\19\0\0007\18\3\0\16\20\12\0\16\21\16\0>\18\4\0027\18\4\0188\18\0\18\18\18\18\0009\18\16\0176\17\12\8'\18\0\0009\18\16\17K\13å\127\16\13\2\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9Ñ\127\16\9\1\0\21\ \0\5'\11\1\0I\9\16€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9ð\127+\9\3\0007\9\5\9'\ \1\0\16\11\7\0\16\12\8\0>\9\4\0012\9\0\0002\ \0\0'\11\0\0'\12\0\0\21\13\0\5'\14\1\0I\12*€2\16\0\0002\17\0\0009\17\15\ 9\16\15\9'\16\0\0\21\17\0\6'\18\1\0I\16!€6\20\15\0076\20\19\0206\21\15\0086\21\19\21+\22\4\0 \23\20\20 \24\21\21\30\23\24\23>\22\2\0026\23\15\0099\22\19\23+\23\5\0\16\24\11\0\16\25\22\0>\23\3\2\16\11\23\0+\23\6\0\16\24\21\0\16\25\20\0>\23\3\2+\24\7\0+\25\8\0\30\25\25\23\22\25\3\25+\26\8\0\27\26\1\26!\25\26\25\20\25\4\25>\24\2\2\16\23\24\0006\24\15\ 9\23\19\24K\16ß\127K\12Ö\127(\12\5\0\1\11\12\0T\12\2€'\12\1\0T\13\4€+\12\2\0\20\13\0\11>\12\2\2\28\12\3\12+\13\9\0007\13\6\13\16\14\6\0\16\15\5\0>\13\3\2+\14\9\0007\14\6\14\16\15\6\0\16\16\5\0>\14\3\2'\15\0\0\21\16\0\5'\17\1\0I\0150€'\19\0\0\21\20\0\6'\21\1\0I\19+€6\23\18\0096\23\22\23(\24\5\0\1\23\24\0T\24\2€'\23\0\0T\24\4€+\24\2\0\20\25\0\23>\24\2\2 \23\24\12+\24\ \0\16\25\23\0'\26ÿ\0>\24\3\2\16\23\24\0'\24\0\0'\25\2\0'\26\1\0I\24\8€\16\29\13\0007\28\3\13\16\30\18\0\16\31\22\0>\28\4\0027\28\4\0289\23\27\28K\24ø\127'\24\0\0'\25\2\0'\26\1\0I\24\ €\16\29\14\0007\28\3\14\16\30\18\0\16\31\22\0>\28\4\0027\28\4\0286\29\18\ 6\29\22\0299\29\27\28K\24ö\127K\19Õ\127K\15Ð\127\16\15\13\0\16\16\14\0F\15\3\0\1À\8À\5À\2À\6À\9À\4À\7À\3À\0À\ À\9flat\ fft2D\8rgb\7at\ width\11height\12RGB2YIQ\2\4\0þ\3\1€€€ÿ\3›¶¯‹\20÷Ãõ\3ú\1\3\0\15\0\20\0\"4\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\0\0%\3\3\0>\2\2\0024\3\4\0007\3\5\0034\4\4\0007\4\6\0044\5\4\0007\5\7\0054\6\4\0007\6\8\0064\7\4\0007\7\9\0074\8\4\0007\8\ \0084\9\4\0007\9\11\0094\ \4\0007\ \12\ 1\11\13\0001\12\14\0001\13\15\0003\14\16\0:\11\17\14:\12\18\14:\13\19\0140\0\0€H\14\2\0\8dft\13dftPhase\17dftMagnitude\1\0\0\0\0\0\8min\8max\9ceil\ floor\9sqrt\8log\ atan2\7pi\9math\14il.fftlib\13il.color\ image\12require\0" ) package.preload["il.fftlib"] = load( "\27LJ\1\2Ã\4\0\3\30\0\6\2ˆ\1\19\3\1\0\20\3\0\3\23\4\1\3\21\5\0\0034\6\0\0007\6\1\0064\7\0\0007\7\2\7\16\8\3\0>\7\2\0024\8\0\0007\8\2\8'\9\2\0>\8\2\2!\7\8\7>\6\2\2'\7\2\0#\7\6\7\4\3\7\0T\7\2€)\7\0\0H\7\2\0'\7\0\0\1\0\7\0T\7\8€'\7\0\0\16\8\5\0'\9\1\0I\7\4€6\11\ \2\18\11\11\0009\11\ \2K\7ü\127\16\7\4\0'\8\1\0\21\9\0\5'\ \1\0I\8\19€\1\11\7\0T\12\8€6\12\7\0026\13\11\0019\13\7\0019\12\11\0016\12\7\0026\13\11\0029\13\7\0029\12\11\2\16\12\4\0\3\12\7\0T\13\4€Q\13\3€\31\7\12\7\23\12\1\12T\13ú\127\30\7\12\7K\8í\127'\8\1\0'\9\0\0\21\ \0\6'\11\1\0I\9:€\16\13\8\0\30\8\8\8'\14\1\0'\15\0\0004\16\0\0007\16\3\0164\17\0\0007\17\4\17!\17\13\17>\16\2\0024\17\0\0007\17\5\0174\18\0\0007\18\4\18!\18\13\18>\17\2\2\18\17\17\0'\18\0\0\21\19\0\13'\20\1\0I\18$€\16\22\21\0\21\23\0\3\16\24\8\0I\22\24€\30\26\13\0256\27\26\1 \27\14\0276\28\26\2 \28\15\28\31\27\28\0276\28\26\1 \28\15\0286\29\26\2 \29\14\29\30\28\29\0286\29\25\1\31\29\27\0299\29\26\0016\29\25\2\31\29\28\0299\29\26\0026\29\25\1\30\29\27\0299\29\25\0016\29\25\2\30\29\28\0299\29\25\2K\22è\127 \22\16\14 \23\17\15\31\22\23\22 \23\17\14 \24\16\15\30\15\24\23\16\14\22\0K\18Ü\127K\9Æ\127'\9\0\0\3\9\0\0T\9\11€'\9\0\0\21\ \0\3'\11\1\0I\9\7€6\13\12\1!\13\3\0139\13\12\0016\13\12\2!\13\3\0139\13\12\2K\9ù\127)\9\2\0H\9\2\0\8sin\7pi\8cos\8log\9ceil\9math\2\4ê\2\0\5\30\0\3\1U\19\5\0\0\20\5\0\5\21\6\0\0054\7\0\0007\7\1\0074\8\0\0007\8\2\8\16\9\5\0>\8\2\0024\9\0\0007\9\2\9'\ \2\0>\9\2\2!\8\9\8>\7\2\2'\8\1\0\21\9\0\6'\ \1\0I\8\12€6\12\11\2\1\11\12\0T\13\8€6\13\12\0006\14\11\0009\14\12\0009\13\11\0006\13\12\0016\14\11\0019\14\12\0019\13\11\1K\8ô\127'\8\1\0'\9\0\0\21\ \0\7'\11\1\0I\9/€\16\13\8\0\30\8\8\8'\14\1\0'\15\0\0006\16\12\0036\17\12\4'\18\0\0\21\19\0\13'\20\1\0I\18$€\16\22\21\0\21\23\0\5\16\24\8\0I\22\24€\30\26\13\0256\27\26\0 \27\14\0276\28\26\1 \28\15\28\31\27\28\0276\28\26\0 \28\15\0286\29\26\1 \29\14\29\30\28\29\0286\29\25\0\31\29\27\0299\29\26\0006\29\25\1\31\29\28\0299\29\26\0016\29\25\0\30\29\27\0299\29\25\0006\29\25\1\30\29\28\0299\29\25\1K\22è\127 \22\16\14 \23\17\15\31\22\23\22 \23\17\14 \24\16\15\30\15\24\23\16\14\22\0K\18Ü\127K\9Ñ\127)\9\2\0H\9\2\0\8log\9ceil\9math\2Ñ\6\0\3\27\1\7\2Ê\1\19\3\1\0\20\3\0\0038\4\0\1\19\4\4\0\20\4\0\0044\5\0\0007\5\1\0054\6\0\0007\6\2\6\16\7\3\0>\6\2\0024\7\0\0007\7\2\7'\8\2\0>\7\2\2!\6\7\6>\5\2\0024\6\0\0007\6\1\0064\7\0\0007\7\2\7\16\8\4\0>\7\2\0024\8\0\0007\8\2\8'\9\2\0>\8\2\2!\7\8\7>\6\2\2'\7\2\0#\7\5\7\5\3\7\0T\7\4€'\7\2\0#\7\6\7\4\4\7\0T\7\2€)\7\0\0H\7\2\0004\7\0\0007\7\3\7\16\8\3\0\16\9\4\0>\7\3\0024\8\0\0007\8\3\8\16\9\5\0\16\ \6\0>\8\3\0022\9\0\0002\ \0\0'\11\1\0'\12\0\0\21\13\0\8'\14\1\0I\12\17€4\16\0\0007\16\4\0164\17\0\0007\17\5\17!\17\11\17>\16\2\0029\16\15\0094\16\0\0007\16\6\0164\17\0\0007\17\5\17!\17\11\17>\16\2\2\18\16\16\0009\16\15\ \22\11\1\11K\12ï\127'\12\0\0\1\0\12\0T\12\15€'\12\0\0\21\13\0\3'\14\1\0I\12\11€'\16\0\0\21\17\0\4'\18\1\0I\16\6€6\20\15\0026\21\15\0026\21\19\21\18\21\21\0009\21\19\20K\16ú\127K\12õ\127\23\12\1\4\21\13\0\4\16\11\12\0002\14\0\0'\15\1\0\21\16\0\13'\17\1\0I\15\ €9\11\18\14\16\19\12\0\3\19\11\0T\20\4€Q\20\3€\31\11\19\11\23\19\1\19T\20ú\127\30\11\19\11K\15ö\127'\15\0\0\21\16\0\3'\17\1\0I\15\8€+\19\0\0006\20\18\0016\21\18\2\16\22\14\0\16\23\9\0\16\24\ \0>\19\6\1K\15ø\127\4\3\4\0T\15\17€\23\12\1\3\21\13\0\3\16\11\12\0'\15\1\0\21\16\0\13'\17\1\0I\15\ €9\11\18\14\16\19\12\0\3\19\11\0T\20\4€Q\20\3€\31\11\19\11\23\19\1\19T\20ú\127\30\11\19\11K\15ö\1272\15\0\0002\16\0\0'\17\0\0\21\18\0\4'\19\1\0I\17\30€'\21\0\0\21\22\0\3'\23\1\0I\21\7€6\25\24\0016\25\20\0259\25\24\0156\25\24\0026\25\20\0259\25\24\16K\21ù\127+\21\0\0\16\22\15\0\16\23\16\0\16\24\14\0\16\25\9\0\16\26\ \0>\21\6\1'\21\0\0\21\22\0\3'\23\1\0I\21\7€6\25\24\0016\26\24\0159\26\20\0256\25\24\0026\26\24\0169\26\20\25K\21ù\127K\17â\127\30\17\6\5\23\17\1\17'\18\2\0#\7\17\18'\17\0\0\21\18\0\3'\19\1\0I\17\16€'\21\0\0\21\22\0\4'\23\1\0I\21\11€6\25\20\0016\26\20\0016\26\24\26!\26\7\0269\26\24\0256\25\20\0026\26\20\0026\26\24\26!\26\7\0269\26\24\25K\21õ\127K\17ð\127)\17\2\0H\17\2\0\1À\8sin\7pi\8cos\8max\8log\9ceil\9math\2\0049\3\0\4\0\6\0\0081\0\0\0001\1\1\0001\2\2\0003\3\3\0:\0\4\3:\2\5\0030\0\0€H\3\2\0\ fft2D\ fft1D\1\0\0\0\0\0\0" ) package.preload["il.freqfilt"] = load( "\27LJ\1\2²\4\0\5\25\0\0\2Š\1\19\5\0\0\20\5\0\0058\6\0\0\19\6\6\0\20\6\0\6\23\7\1\5\23\8\1\6\21\9\0\5\21\ \0\6'\11\0\0\21\12\0\7'\13\1\0I\11|€ \15\14\14'\16\0\0\21\17\0\8'\18\1\0I\16v€ \20\19\19\30\21\20\15\3\21\2\0T\0219€6\21\14\0006\22\14\0006\22\19\22 \22\3\0229\22\19\0216\21\14\0016\22\14\0016\22\19\22 \22\3\0229\22\19\21\31\21\14\0096\21\21\0\31\22\14\0096\22\22\0006\22\19\22 \22\3\0229\22\19\21\31\21\14\0096\21\21\1\31\22\14\0096\22\22\0016\22\19\22 \22\3\0229\22\19\0216\21\14\0\31\22\19\ 6\23\14\0\31\24\19\ 6\23\24\23 \23\3\0239\23\22\0216\21\14\1\31\22\19\ 6\23\14\1\31\24\19\ 6\23\24\23 \23\3\0239\23\22\21\31\21\14\0096\21\21\0\31\22\19\ \31\23\14\0096\23\23\0\31\24\19\ 6\23\24\23 \23\3\0239\23\22\21\31\21\14\0096\21\21\1\31\22\19\ \31\23\14\0096\23\23\1\31\24\19\ 6\23\24\23 \23\3\0239\23\22\21T\0218€6\21\14\0006\22\14\0006\22\19\22 \22\4\0229\22\19\0216\21\14\0016\22\14\0016\22\19\22 \22\4\0229\22\19\21\31\21\14\0096\21\21\0\31\22\14\0096\22\22\0006\22\19\22 \22\4\0229\22\19\21\31\21\14\0096\21\21\1\31\22\14\0096\22\22\0016\22\19\22 \22\4\0229\22\19\0216\21\14\0\31\22\19\ 6\23\14\0\31\24\19\ 6\23\24\23 \23\4\0239\23\22\0216\21\14\1\31\22\19\ 6\23\14\1\31\24\19\ 6\23\24\23 \23\4\0239\23\22\21\31\21\14\0096\21\21\0\31\22\19\ \31\23\14\0096\23\23\0\31\24\19\ 6\23\24\23 \23\4\0239\23\22\21\31\21\14\0096\21\21\1\31\22\19\ \31\23\14\0096\23\23\1\31\24\19\ 6\23\24\23 \23\4\0239\23\22\21K\16Š\127K\11„\127G\0\1\0\2\4\5\0\5\27\1\0\3 \1\19\5\1\0\20\5\0\0058\6\0\1\19\6\6\0\20\6\0\6\23\7\1\5\23\8\1\6\21\9\0\5\21\ \0\6'\11\0\0'\12\0\0\21\13\0\7'\14\1\0I\12F€ \16\11\11'\17\0\0'\18\0\0\21\19\0\8'\20\1\0I\18\31€\9\17\2\0T\22\3€\9\11\2\0T\22\1€T\18\26€ \22\17\17+\23\0\0\30\24\16\22\18\24\24\0\27\25\1\3!\24\25\24>\23\2\2\15\0\0\0T\24\2€\14\0\23\0T\24\1€\26\23\0\0236\24\15\0016\25\15\0016\25\21\25\30\26\4\23 \25\26\0259\25\21\0246\24\15\0026\25\15\0026\25\21\25\30\26\4\23 \25\26\0259\25\21\24\20\17\0\17K\18á\127\18\17\8\0\16\18\8\0\21\19\0\6'\20\1\0I\18\26€ \22\17\17+\23\0\0\30\24\16\22\18\24\24\0\27\25\1\3!\24\25\24>\23\2\2\15\0\0\0T\24\2€\14\0\23\0T\24\1€\26\23\0\0236\24\15\0016\25\15\0016\25\21\25\30\26\4\23 \25\26\0259\25\21\0246\24\15\0026\25\15\0026\25\21\25\30\26\4\23 \25\26\0259\25\21\24\20\17\0\17K\18æ\127\21\11\0\11K\12º\127\21\11\0\8\16\12\7\0\21\13\0\5'\14\1\0I\12F€ \16\11\11'\17\0\0'\18\0\0\21\19\0\8'\20\1\0I\18\31€\9\17\2\0T\22\3€\9\11\2\0T\22\1€T\18\26€ \22\17\17+\23\0\0\30\24\16\22\18\24\24\0\27\25\1\3!\24\25\24>\23\2\2\15\0\0\0T\24\2€\14\0\23\0T\24\1€\26\23\0\0236\24\15\0016\25\15\0016\25\21\25\30\26\4\23 \25\26\0259\25\21\0246\24\15\0026\25\15\0026\25\21\25\30\26\4\23 \25\26\0259\25\21\24\20\17\0\17K\18á\127\18\17\8\0\16\18\8\0\21\19\0\6'\20\1\0I\18\26€ \22\17\17+\23\0\0\30\24\16\22\18\24\24\0\27\25\1\3!\24\25\24>\23\2\2\15\0\0\0T\24\2€\14\0\23\0T\24\1€\26\23\0\0236\24\15\0016\25\15\0016\25\21\25\30\26\4\23 \25\26\0259\25\21\0246\24\15\0026\25\15\0026\25\21\25\30\26\4\23 \25\26\0259\25\21\24\20\17\0\17K\18æ\127\21\11\0\11K\12º\127G\0\1\0\6À\2\4\0’\3\0\1\22\3\4\1\\7\1\0\0007\2\1\0+\3\0\0+\4\1\0\16\5\1\0>\4\2\2+\5\1\0'\6\2\0>\5\2\2!\4\5\4>\3\2\2+\4\0\0+\5\1\0\16\6\2\0>\5\2\2+\6\1\0'\7\2\0>\6\2\2!\5\6\5>\4\2\2'\5\2\0#\5\3\5'\6\2\0#\6\4\6+\7\2\0\16\8\5\0\16\9\6\0>\7\3\2\16\5\7\0\16\6\5\0002\7\0\0002\8\0\0'\9\0\0\21\ \0\1'\11\1\0I\9!€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\2'\15\1\0I\13\13€6\17\12\7\16\19\0\0007\18\2\0\16\20\12\0\16\21\16\0>\18\4\0027\18\3\0188\18\0\0189\18\16\0176\17\12\8'\18\0\0009\18\16\17K\13ó\127\16\13\2\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9ß\127\16\9\1\0\21\ \0\5'\11\1\0I\9\16€2\13\0\0002\14\0\0009\14\12\0089\13\12\7'\13\0\0\21\14\0\6'\15\1\0I\13\7€6\17\12\0076\18\12\8'\19\0\0'\20\0\0009\20\16\0189\19\16\17K\13ù\127K\9ð\127\16\9\7\0\16\ \8\0F\9\3\0\8À\5À\3À\8rgb\7at\ width\11height\2ç\4\0\6 \8\11\5~\14\0\0\0T\6\2€)\6\0\0H\6\2\0\15\0\1\0T\6\2€\14\0\2\0T\6\1€H\0\2\0\14\0\3\0T\6\1€'\3\0\0\14\0\4\0T\6\1€'\4\1\0\14\0\5\0T\6\1€'\5\1\0+\6\0\0007\6\0\6\16\7\0\0>\6\2\2\16\0\6\0007\6\1\0007\7\2\0+\8\1\0\16\9\0\0>\8\2\3\19\ \8\0\20\ \0\ 8\11\0\8\19\11\11\0\20\11\0\11\23\12\1\ \23\13\1\11\23\14\2\2 \2\12\14 \14\2\2+\15\2\0\20\16\3\14>\15\2\2+\16\3\0007\16\3\16'\17\1\0\16\18\8\0\16\19\9\0>\16\4\1\7\1\4\0T\16\8€+\16\4\0\16\17\8\0\16\18\9\0\16\19\15\0\30\20\3\4\30\21\3\5>\16\6\1T\16\19€\7\1\5\0T\16\8€+\16\5\0)\17\2\0\16\18\8\0\16\19\9\0\16\20\14\0\16\21\3\0>\16\6\1T\16\9€\7\1\6\0T\16\7€+\16\5\0)\17\1\0\16\18\8\0\16\19\9\0\16\20\14\0\16\21\3\0>\16\6\1+\16\3\0007\16\3\16'\17ÿÿ\16\18\8\0\16\19\9\0>\16\4\1\16\17\0\0007\16\7\0>\16\2\2'\17\0\0\21\18\0\6'\19\1\0I\17!€'\21\0\0\21\22\0\7'\23\1\0I\21\28€6\25\20\0086\25\24\0256\26\20\0096\26\24\26 \27\25\25 \28\26\26\30\27\28\27(\28\4\0\1\27\28\0T\28\2€'\27\0\0T\28\4€+\28\6\0\16\29\27\0>\28\2\2\16\27\28\0\16\29\16\0007\28\8\16\16\30\20\0\16\31\24\0>\28\4\0027\28\9\28+\29\7\0\16\30\27\0'\31ÿ\0>\29\3\2;\29\0\28K\21ä\127K\17ß\127+\17\0\0007\17\ \17\16\18\16\0@\17\2\0\0À\11À\7À\1À\9À\ À\4À\2À\12YIQ2RGB\8rgb\7at\ clone\13gaussHPF\13gaussLPF\ ideal\ fft2D\ width\11height\12RGB2YIQ\2\4È\1\1€€€ÿ\3\1€€Àþ\3Î\1\3\0\14\0\17\0\0284\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\0024\3\3\0007\3\5\0034\4\3\0007\4\6\0044\5\3\0007\5\7\0054\6\3\0007\6\8\0064\7\3\0007\7\9\0074\8\3\0007\8\ \0081\9\11\0001\ \12\0001\11\13\0001\12\14\0003\13\15\0:\12\16\0130\0\0€H\13\2\0\20frequencyFilter\1\0\0\0\0\0\0\9ceil\ floor\8exp\8log\9sqrt\8max\8min\9math\14il.fftlib\13il.color\12require\0" ) package.preload["il.histo"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\3À\1€€€ÿ\3¢\1\0\1\15\0\3\1#2\1\0\0'\2\0\0'\3\2\0'\4\1\0I\2\29€2\6\0\0009\6\5\1'\6\0\0'\7ÿ\0'\8\1\0I\6\4€6\ \5\1'\11\0\0009\11\9\ K\6ü\127\16\7\0\0007\6\0\0>\6\2\4T\9\12€\16\12\0\0007\11\1\0\16\13\9\0\16\14\ \0>\11\4\0027\11\2\0116\11\5\0116\12\5\0016\13\5\0016\13\11\13\20\13\0\0139\13\11\12A\9\3\3N\9ò\127K\2ã\127H\1\2\0\8rgb\7at\11pixels\2Á\2\0\2\12\2\4\5A\7\1\0\0T\2\3€+\2\0\0\16\3\0\0@\2\2\0002\2\0\0'\3\0\0'\4ÿ\0'\5\1\0I\3\3€'\7\0\0009\7\6\2K\3ý\127\7\1\1\0T\3\24€\16\4\0\0007\3\2\0>\3\2\4T\6\17€\16\9\0\0007\8\3\0\16\ \6\0\16\11\7\0>\8\4\0027\8\0\8+\9\1\0008\ \0\0088\11\1\8\30\ \11\ 8\11\2\8\30\ \11\ \23\ \0\ >\9\2\0026\ \9\2\20\ \1\ 9\ \9\2A\6\3\3N\6í\127T\3\25€\16\4\0\0007\3\2\0>\3\2\4T\6\19€\16\9\0\0007\8\3\0\16\ \6\0\16\11\7\0>\8\4\0027\8\0\8+\9\1\0008\ \0\8\27\ \2\ 8\11\1\8\27\11\3\11\30\ \11\ 8\11\2\8\27\11\4\11\30\ \11\ >\9\2\0026\ \9\2\20\ \1\ 9\ \9\2A\6\3\3N\6ë\127H\2\2\0\5À\4À\7at\11pixels\8ihs\8rgb\6\2ç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3º\4\0\2\17\4\11\2y\7\1\0\0T\2\6€+\2\0\0007\2\1\2\16\3\0\0>\2\2\2\16\0\2\0T\2\13€\7\1\2\0T\2\6€+\2\0\0007\2\3\2\16\3\0\0>\2\2\2\16\0\2\0T\2\5€+\2\0\0007\2\4\2\16\3\0\0>\2\2\2\16\0\2\0'\2ÿ\0'\3\0\0002\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\3€'\9\0\0009\9\8\4K\5ý\127\16\6\0\0007\5\5\0>\5\2\4T\8\19€\16\11\0\0007\ \6\0\16\12\8\0\16\13\9\0>\ \4\0027\ \7\ 6\11\ \4\20\11\0\0119\11\ \4+\11\1\0\16\12\2\0\16\13\ \0>\11\3\2\16\2\11\0+\11\2\0\16\12\3\0\16\13\ \0>\11\3\2\16\3\11\0A\8\3\3N\8ë\127\31\5\2\3\28\5\1\0052\6\0\0'\7\0\0\16\8\2\0'\9\1\0I\7\3€'\11\0\0009\11\ \6K\7ý\127\16\7\3\0'\8ÿ\0'\9\1\0I\7\3€'\11ÿ\0009\11\ \6K\7ý\127\16\7\2\0\16\8\3\0'\9\1\0I\7\6€+\11\3\0\31\12\2\ \12\12\5>\11\2\0029\11\ \6K\7ú\127\16\8\0\0007\7\5\0>\7\2\4T\ \13€\16\13\0\0007\12\6\0\16\14\ \0\16\15\11\0>\12\4\2\16\14\0\0007\13\6\0\16\15\ \0\16\16\11\0>\13\4\0027\13\7\0136\13\13\6:\13\7\12A\ \3\3N\ ñ\127\7\1\0\0T\7\5€+\7\0\0007\7\8\7\16\8\0\0@\7\2\0T\7\11€\7\1\2\0T\7\5€+\7\0\0007\7\9\7\16\8\0\0@\7\2\0T\7\4€+\7\0\0007\7\ \7\16\8\0\0@\7\2\0G\0\1\0\0À\2À\1À\4À\12YIQ2RGB\12YUV2RGB\12IHS2RGB\6y\7at\11pixels\12RGB2YIQ\12RGB2YUV\8yuv\12RGB2IHS\8ihs\2þ\3¶\5\0\4\22\2\13\3•\1\7\3\0\0T\4\6€+\4\0\0007\4\1\4\16\5\0\0>\4\2\2\16\0\4\0T\4\13€\7\3\2\0T\4\6€+\4\0\0007\4\3\4\16\5\0\0>\4\2\2\16\0\4\0T\4\5€+\4\0\0007\4\4\4\16\5\0\0>\4\2\2\16\0\4\0002\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\3€'\9\0\0009\9\8\4K\5ý\127\16\6\0\0007\5\5\0>\5\2\4T\8\9€\16\11\0\0007\ \6\0\16\12\8\0\16\13\9\0>\ \4\0027\ \7\ 6\11\ \4\20\11\0\0119\11\ \4A\8\3\3N\8õ\127'\5\0\0'\6\0\0\14\0\1\0T\7\1€'\1\1\0\14\0\2\0T\7\1€\26\2\1\0017\7\8\0007\8\9\0 \7\8\7 \8\1\7\23\8\1\8 \9\2\7\23\2\1\9\16\1\8\0'\8\0\0'\9ÿ\0'\ \1\0I\8\7€6\12\11\4\30\6\12\6\3\1\6\0T\12\2€\16\5\11\0T\8\1€K\8ù\127'\8ÿ\0'\9\0\0'\ \0\0'\11ÿ\0'\12\1\0I\ \7€6\14\13\4\30\9\14\9\3\2\9\0T\14\2€\16\8\13\0T\ \1€K\ ù\127\31\ \5\8\28\ \2\ 2\11\0\0'\12\0\0\16\13\5\0'\14\1\0I\12\3€'\16\0\0009\16\15\11K\12ý\127\16\12\8\0'\13ÿ\0'\14\1\0I\12\3€'\16ÿ\0009\16\15\11K\12ý\127\16\12\5\0\16\13\8\0'\14\1\0I\12\6€+\16\1\0\31\17\5\15 \17\17\ >\16\2\0029\16\15\11K\12ú\127\16\13\0\0007\12\5\0>\12\2\4T\15\13€\16\18\0\0007\17\6\0\16\19\15\0\16\20\16\0>\17\4\2\16\19\0\0007\18\6\0\16\20\15\0\16\21\16\0>\18\4\0027\18\7\0186\18\18\11:\18\7\17A\15\3\3N\15ñ\127\7\3\0\0T\12\5€+\12\0\0007\12\ \12\16\13\0\0@\12\2\0T\12\11€\7\3\2\0T\12\5€+\12\0\0007\12\11\12\16\13\0\0@\12\2\0T\12\4€+\12\0\0007\12\12\12\16\13\0\0@\12\2\0G\0\1\0\0À\4À\12YIQ2RGB\12YUV2RGB\12IHS2RGB\ width\11height\6y\7at\11pixels\12RGB2YIQ\12RGB2YUV\8yuv\12RGB2IHS\8ihs\2È\1þ\3Ó\2\0\1\17\1\5\2K7\1\0\0007\2\1\0 \1\2\1\28\1\0\0012\2\0\0'\3\0\0'\4\2\0'\5\1\0I\3A€'\7\0\0'\8ÿ\0'\9\1\0I\7\3€'\11\0\0009\11\ \2K\7ý\127\16\8\0\0007\7\2\0>\7\2\4T\ \ €\16\13\0\0007\12\3\0\16\14\ \0\16\15\11\0>\12\4\0027\12\4\0126\12\6\0126\13\12\2\20\13\1\0139\13\12\2A\ \3\3N\ ô\127'\7\1\0'\8ÿ\0'\9\1\0I\7\6€6\11\ \2\21\12\1\ 6\12\12\2\30\11\12\0119\11\ \2K\7ú\127'\7\0\0'\8ÿ\0'\9\1\0I\7\6€+\11\0\0006\12\ \2 \12\1\12>\11\2\0029\11\ \2K\7ú\127\16\8\0\0007\7\2\0>\7\2\4T\ \15€\16\13\0\0007\12\3\0\16\14\ \0\16\15\11\0>\12\4\0027\12\4\12\16\14\0\0007\13\3\0\16\15\ \0\16\16\11\0>\13\4\0027\13\4\0136\13\6\0136\13\13\0029\13\6\12A\ \3\3N\ ï\127K\3¿\127H\0\2\0\4À\8rgb\7at\11pixels\ width\11heightþ\3\2¡\4\0\2\14\3\14\2o\7\1\0\0T\2\3€+\2\0\0\16\3\0\0@\2\2\0\7\1\1\0T\2\6€+\2\1\0007\2\2\2\16\3\0\0>\2\2\2\16\0\2\0T\2\13€\7\1\3\0T\2\6€+\2\1\0007\2\4\2\16\3\0\0>\2\2\2\16\0\2\0T\2\5€+\2\1\0007\2\5\2\16\3\0\0>\2\2\2\16\0\2\0002\2\0\0'\3\0\0'\4ÿ\0'\5\1\0I\3\3€'\7\0\0009\7\6\2K\3ý\127\16\4\0\0007\3\6\0>\3\2\4T\6\9€\16\9\0\0007\8\7\0\16\ \6\0\16\11\7\0>\8\4\0027\8\8\0086\9\8\2\20\9\0\0099\9\8\2A\6\3\3N\6õ\127'\3\1\0'\4ÿ\0'\5\1\0I\3\6€6\7\6\2\21\8\0\0066\8\8\2\30\7\8\0079\7\6\2K\3ú\1277\3\9\0007\4\ \0 \3\4\3\28\3\1\3'\4\0\0'\5ÿ\0'\6\1\0I\4\6€+\8\2\0006\9\7\2 \9\3\9>\8\2\0029\8\7\2K\4ú\127\16\5\0\0007\4\6\0>\4\2\4T\7\13€\16\ \0\0007\9\7\0\16\11\7\0\16\12\8\0>\9\4\2\16\11\0\0007\ \7\0\16\12\7\0\16\13\8\0>\ \4\0027\ \8\ 6\ \ \2:\ \8\9A\7\3\3N\7ñ\127\7\1\1\0T\4\5€+\4\1\0007\4\11\4\16\5\0\0@\4\2\0T\4\11€\7\1\3\0T\4\5€+\4\1\0007\4\12\4\16\5\0\0@\4\2\0T\4\4€+\4\1\0007\4\13\4\16\5\0\0@\4\2\0G\0\1\0\9À\0À\4À\12YIQ2RGB\12YUV2RGB\12IHS2RGB\ width\11height\6y\7at\11pixels\12RGB2YIQ\12RGB2YUV\8yuv\12RGB2IHS\8ihs\8rgb\2þ\3\29\0\1\4\1\1\0\4+\1\0\0\16\2\0\0%\3\0\0@\1\3\0\ À\8yiq\29\0\1\4\1\1\0\4+\1\0\0\16\2\0\0%\3\0\0@\1\3\0\ À\8yuv\29\0\1\4\1\1\0\4+\1\0\0\16\2\0\0%\3\0\0@\1\3\0\ À\8ihsÕ\4\0\3\15\2\13\3}'\3\0\0\2\1\3\0T\3\3€'\3d\0\1\3\1\0T\3\1€H\0\2\0\7\2\0\0T\3\6€+\3\0\0007\3\1\3\16\4\0\0>\3\2\2\16\0\3\0T\3\13€\7\2\2\0T\3\6€+\3\0\0007\3\3\3\16\4\0\0>\3\2\2\16\0\3\0T\3\5€+\3\0\0007\3\4\3\16\4\0\0>\3\2\2\16\0\3\0002\3\0\0'\4\0\0'\5ÿ\0'\6\1\0I\4\3€'\8\0\0009\8\7\3K\4ý\127\16\5\0\0007\4\5\0>\4\2\4T\7\9€\16\ \0\0007\9\6\0\16\11\7\0\16\12\8\0>\9\4\0027\9\7\0096\ \9\3\20\ \0\ 9\ \9\3A\7\3\3N\7õ\1277\4\8\0007\5\9\0 \4\5\4 \4\1\4\23\1\1\4'\4\0\0'\5ÿ\0'\6\1\0I\4\5€6\8\7\3\1\1\8\0T\8\1€9\1\7\3K\4û\127'\4\1\0'\5ÿ\0'\6\1\0I\4\6€6\8\7\3\21\9\0\0076\9\9\3\30\8\9\0089\8\7\3K\4ú\1278\4ÿ\3\28\4\2\4'\5\0\0'\6ÿ\0'\7\1\0I\5\6€+\9\1\0006\ \8\3 \ \4\ >\9\2\0029\9\8\3K\5ú\127\16\6\0\0007\5\5\0>\5\2\4T\8\13€\16\11\0\0007\ \6\0\16\12\8\0\16\13\9\0>\ \4\2\16\12\0\0007\11\6\0\16\13\8\0\16\14\9\0>\11\4\0027\11\7\0116\11\11\3:\11\7\ A\8\3\3N\8ñ\127\7\2\0\0T\5\5€+\5\0\0007\5\ \5\16\6\0\0@\5\2\0T\5\11€\7\2\2\0T\5\5€+\5\0\0007\5\11\5\16\6\0\0@\5\2\0T\5\4€+\5\0\0007\5\12\5\16\6\0\0@\5\2\0G\0\1\0\0À\4À\12YIQ2RGB\12YUV2RGB\12IHS2RGB\ width\11height\6y\7at\11pixels\12RGB2YIQ\12RGB2YUV\8yuv\12RGB2IHS\8ihs\2È\1þ\3±\2\3\0\16\0\28\0!4\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0014\2\2\0007\2\4\0024\3\2\0007\3\5\0031\4\6\0001\5\7\0001\6\8\0001\7\9\0001\8\ \0001\9\11\0001\ \12\0001\11\13\0001\12\14\0001\13\15\0001\14\16\0003\15\17\0:\6\18\15:\5\19\15:\7\20\15:\8\21\15:\ \22\15:\11\23\15:\12\24\15:\13\25\15:\9\26\15:\14\27\0150\0\0€H\15\2\0\17equalizeClip\16equalizeRGB\16equalizeIHS\16equalizeYUV\16equalizeYIQ\13equalize\19stretchSpecify\12stretch\17histogramRGB\14histogram\1\0\0\0\0\0\0\0\0\0\0\0\0\0\ floor\8min\8max\9math\13il.color\12require\0" ) package.preload["il.historender"] = load( "\27LJ\1\2Å\1\0\1\15\3\4\1('\1\0\0'\2\0\0'\3ÿ\0'\4\1\0I\2\6€+\6\0\0\16\7\1\0006\8\5\0>\6\3\2\16\1\6\0K\2ú\127+\2\1\0007\2\0\2'\3\0\1'\4\0\1'\5ÿ\0>\2\4\2'\3\0\0'\4ÿ\0'\5\1\0I\3\18€+\7\2\0006\8\6\0\27\8\0\8!\8\1\8\26\8\0\8>\7\2\2'\8ÿ\0'\9\1\0I\7\8€\16\12\2\0007\11\1\2\16\13\ \0\16\14\6\0>\11\4\0023\12\3\0:\12\2\11K\7ø\127K\3î\127H\2\2\0\3À\0À\2À\1\4\0\0\3\0\3\0\3\0\8rgb\7at\9flatþ\3®\2\0\1\20\3\6\2<'\1\0\0'\2\0\0'\3\2\0'\4\1\0I\2\12€'\6\0\0'\7ÿ\0'\8\1\0I\6\7€+\ \0\0\16\11\1\0006\12\5\0006\12\9\12>\ \3\2\16\1\ \0K\6ù\127K\2ô\1272\2\0\0003\3\0\0003\4\1\0003\5\2\0;\5\2\2;\4\1\2;\3\0\2+\3\1\0007\3\3\3'\4\0\3'\5\0\1'\6ÿ\0>\3\4\2'\4\0\0'\5\2\0'\6\1\0I\4\25€'\8\0\0'\9ÿ\0'\ \1\0I\8\20€+\12\2\0006\13\7\0006\13\11\13\27\13\0\13!\13\1\13\26\13\0\13>\12\2\2'\13ÿ\0'\14\1\0I\12\9€\16\17\3\0007\16\4\3\16\18\15\0\22\19\1\7\30\19\19\11>\16\4\0026\17\7\2:\17\5\16K\12÷\127K\8ì\127K\4ç\127H\3\2\0\3À\0À\2À\8rgb\7at\9flat\1\4\0\0\3\0\3\0\3ÿ\1\1\4\0\0\3\0\3ÿ\1\3\0\1\4\0\0\3ÿ\1\3\0\3\0þ\3€\4;\0\2\4\2\1\0\11\7\1\0\0T\2\5€+\2\0\0\16\3\0\0>\2\2\2\14\0\2\0T\3\3€+\2\1\0\16\3\0\0>\2\2\2H\2\2\0\6À\5À\8rgb=\0\2\7\2\1\0\ \16\2\0\0+\3\0\0+\4\1\0007\4\0\4\16\5\0\0\16\6\1\0>\4\3\2\16\5\1\0>\3\3\0E\2\1\0\7À\1À\14histogram8\0\1\5\2\1\0\8\16\1\0\0+\2\0\0+\3\1\0007\3\0\3\16\4\0\0>\3\2\0=\2\0\0E\1\1\0\6À\1À\17histogramRGBó\1\3\0\11\0\18\0\0254\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\0024\3\3\0007\3\5\0034\4\3\0007\4\6\0041\5\7\0001\6\8\0001\7\9\0001\8\ \0001\9\11\0003\ \12\0:\7\13\ :\5\14\ :\6\15\ :\8\16\ :\9\17\ 0\0\0€H\ \2\0\21showHistogramRGB\18showHistogram\23renderHistogramRGB\24renderMonoHistogram\20renderHistogram\1\0\0\0\0\0\0\0\8min\8max\ floor\9math\13il.histo\ image\12require\0" ) package.preload["il.median"] = load( "\27LJ\1\2—\1\0\1\9\1\0\2#'\1\0\0'\2ÿ\0'\3\1\0I\1\4€+\5\0\0'\6\0\0009\6\4\5K\1ü\127\19\1\0\0'\2\1\0\16\3\1\0'\4\1\0I\2\7€6\6\5\0+\7\0\0+\8\0\0006\8\6\8\20\8\0\0089\8\6\7K\2ù\127'\2\0\0\23\1\1\1'\3\0\0'\4ÿ\0'\5\1\0I\3\7€+\7\0\0006\7\6\7\30\2\7\2\3\1\2\0T\7\1€H\6\2\0K\3ù\127'\3\0\0H\3\2\0\2À\2\4æ\2\0\2\27\2\ \2H7\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\3\0>\4\2\2\15\0\1\0T\5\6€4\5\4\0007\5\5\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\4\0007\5\6\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0002\5\0\0\16\6\1\0\31\7\1\2\21\7\1\7'\8\1\0I\6%€\16\ \1\0\31\11\1\3\21\11\1\11'\12\1\0I\ \31€'\14\1\0\18\15\1\0\16\16\1\0'\17\1\0I\15\15€\18\19\1\0\16\20\1\0'\21\1\0I\19\ €\16\24\0\0007\23\7\0\30\25\18\9\30\26\22\13>\23\4\0027\23\8\0238\23\0\0239\23\14\5\20\14\1\14K\19ö\127K\15ñ\127\16\16\4\0007\15\7\4\16\17\9\0\16\18\13\0>\15\4\0027\15\8\15+\16\1\0\16\17\5\0>\16\2\2;\16\0\15K\ á\127K\6Û\127+\6\0\0007\6\9\6\16\7\4\0@\6\2\0\0À\1€\12YIQ2RGB\8rgb\7at\8max\ floor\9math\ clone\12RGB2YIQ\ width\11height\4\2ã\2\0\1\17\2\7\2K7\1\0\0007\2\1\0+\3\0\0007\3\2\3\16\4\0\0>\3\2\2\16\0\3\0\16\4\0\0007\3\3\0>\3\2\0022\4\0\0'\5\1\0\21\6\0\1'\7\1\0I\0058€'\9\1\0\21\ \0\2'\11\1\0I\0093€\16\14\0\0007\13\4\0\16\15\8\0\16\16\12\0>\13\4\0027\13\5\0138\13\0\13;\13\1\4\16\14\0\0007\13\4\0\21\15\1\8\16\16\12\0>\13\4\0027\13\5\0138\13\0\13;\13\2\4\16\14\0\0007\13\4\0\20\15\1\8\16\16\12\0>\13\4\0027\13\5\0138\13\0\13;\13\3\4\16\14\0\0007\13\4\0\16\15\8\0\21\16\1\12>\13\4\0027\13\5\0138\13\0\13;\13\4\4\16\14\0\0007\13\4\0\16\15\8\0\20\16\1\12>\13\4\0027\13\5\0138\13\0\13;\13\5\4\16\14\3\0007\13\4\3\16\15\8\0\16\16\12\0>\13\4\0027\13\5\13+\14\1\0\16\15\4\0>\14\2\2;\14\0\13K\9Í\127K\5È\127+\5\0\0007\5\6\5\16\6\3\0@\5\2\0\0À\1€\12YIQ2RGB\8rgb\7at\ clone\12RGB2YIQ\ width\11height\4\2h\3\0\5\0\8\0\0144\0\0\0%\1\1\0>\0\2\2)\1\0\0002\2\0\0001\1\2\0000\2\0€1\2\3\0001\3\4\0003\4\5\0:\3\6\4:\2\7\0040\0\0€H\4\2\0\11median\15medianPlus\1\0\0\0\0\0\13il.color\12require\0" ) package.preload["il.minmax"] = load( "\27LJ\1\2 \4\0\3\27\1\11\2v7\3\0\0007\4\1\0\15\0\1\0T\5\6€4\5\2\0007\5\3\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\2\0007\5\4\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0\15\0\2\0T\5\4€4\5\2\0007\5\4\5\14\0\5\0T\6\2€4\5\2\0007\5\5\5+\6\0\0007\6\6\6\16\7\0\0>\6\2\2\16\0\6\0\16\7\0\0007\6\7\0>\6\2\2\16\8\0\0007\7\7\0>\7\2\2'\8\0\0\21\9\1\3'\ \1\0I\8#€\16\12\1\0\31\13\1\4\21\13\1\13'\14\1\0I\12\29€\15\0\2\0T\16\2€'\16\0\0T\17\1€'\16ÿ\0\18\17\1\0\16\18\1\0'\19\1\0I\17\12€\16\21\5\0\16\22\16\0\16\24\0\0007\23\8\0\16\25\11\0\30\26\20\15>\23\4\0027\23\9\0238\23\0\23>\21\3\2\16\16\21\0K\17ô\127\16\18\6\0007\17\8\6\16\19\11\0\16\20\15\0>\17\4\0027\17\9\17;\16\0\17K\12ã\127K\8Ý\127'\8\0\0\21\9\1\4'\ \1\0I\8#€\16\12\1\0\31\13\1\3\21\13\1\13'\14\1\0I\12\29€\15\0\2\0T\16\2€'\16\0\0T\17\1€'\16ÿ\0\18\17\1\0\16\18\1\0'\19\1\0I\17\12€\16\21\5\0\16\22\16\0\16\24\6\0007\23\8\6\30\25\20\15\16\26\11\0>\23\4\0027\23\9\0238\23\0\23>\21\3\2\16\16\21\0K\17ô\127\16\18\7\0007\17\8\7\16\19\15\0\16\20\11\0>\17\4\0027\17\9\17;\16\0\17K\12ã\127K\8Ý\127+\8\0\0007\8\ \8\16\9\7\0@\8\2\0\0À\12YIQ2RGB\8rgb\7at\ clone\12RGB2YIQ\8min\8max\ floor\9math\ width\11height\4\2\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\1\0@\2\4\0\1À\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\2\0@\2\4\0\1ÀZ\3\0\5\0\8\0\0114\0\0\0%\1\1\0>\0\2\0021\1\2\0001\2\3\0001\3\4\0003\4\5\0:\2\6\4:\3\7\0040\0\0€H\4\2\0\12maximum\12minimum\1\0\0\0\0\0\13il.color\12require\0" ) package.preload["il.misc"] = load( "\27LJ\1\2'\0\1\5\2\0\0\7+\1\0\0+\2\1\0\16\3\0\0'\4\0\0>\2\3\2'\3ÿ\0@\1\3\0\4À\5Àú\1\0\1\17\2\6\00227\1\0\0007\2\1\0'\3\2\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0'\4\0\0\31\5\3\1\21\5\0\5'\6\1\0I\4!€'\8\0\0\31\9\3\2\21\9\0\9'\ \1\0I\8\27€\16\13\0\0007\12\3\0\16\14\7\0\16\15\11\0>\12\4\0027\12\4\0128\12\0\12\16\14\0\0007\13\3\0\30\15\3\7\30\16\3\11>\13\4\0027\13\4\0138\13\0\13\31\12\13\12\20\12\1\12\16\14\0\0007\13\3\0\16\15\7\0\16\16\11\0>\13\4\0027\13\4\13+\14\1\0\16\15\12\0>\14\2\2;\14\0\13K\8å\127K\4ß\127+\4\0\0007\4\5\4\16\5\0\0@\4\2\0\1À\11À\12YIQ2RGB\8rgb\7at\12RGB2YIQ\ width\11height\2€\2—\3\0\2\21\2\9\1V7\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\3\0\16\6\2\0>\4\3\2+\5\1\0007\5\3\5\16\6\0\0>\5\2\2\16\0\5\0004\5\4\0007\5\5\5\16\7\0\0007\6\6\0'\8\1\0>\6\3\4T\9@€\16\11\5\0\16\13\0\0007\12\7\0\16\14\9\0\16\15\ \0>\12\4\0027\12\8\0128\12\0\12!\12\1\12>\11\2\2 \11\1\11\16\13\0\0007\12\7\0\21\14\0\9\16\15\ \0>\12\4\0027\12\8\0128\12\0\12\0\12\11\0T\12\29€\16\13\0\0007\12\7\0\20\14\0\9\16\15\ \0>\12\4\0027\12\8\0128\12\0\12\0\12\11\0T\12\20€\16\13\0\0007\12\7\0\16\14\9\0\21\15\0\ >\12\4\0027\12\8\0128\12\0\12\0\12\11\0T\12\11€\16\13\0\0007\12\7\0\16\14\9\0\20\15\0\ >\12\4\0027\12\8\0128\12\0\12\0\12\11\0T\12\2€)\12\1\0T\13\1€)\12\2\0\15\0\12\0T\13\12€'\13\0\0'\14\2\0'\15\1\0I\13\8€\16\18\4\0007\17\7\4\16\19\9\0\16\20\ \0>\17\4\0027\17\8\0179\11\16\17K\13ø\127A\9\3\3N\9¾\127H\4\2\0\0À\1À\8rgb\7at\11pixels\ floor\9math\12RGB2YIQ\9flat\ width\11height\2ý\2\0\2\19\1\7\1S\16\3\0\0007\2\0\0>\2\2\2+\3\0\0007\3\1\3\16\4\0\0>\3\2\2\16\0\3\0004\3\2\0007\3\3\3\16\5\0\0007\4\4\0'\6\1\0>\4\3\4T\7A€\16\9\3\0\16\11\0\0007\ \5\0\16\12\7\0\16\13\8\0>\ \4\0027\ \6\ 8\ \0\ !\ \1\ >\9\2\2 \9\1\9\16\11\0\0007\ \5\0\21\12\0\7\16\13\8\0>\ \4\0027\ \6\ 8\ \0\ \0\ \9\0T\ \29€\16\11\0\0007\ \5\0\20\12\0\7\16\13\8\0>\ \4\0027\ \6\ 8\ \0\ \0\ \9\0T\ \20€\16\11\0\0007\ \5\0\16\12\7\0\21\13\0\8>\ \4\0027\ \6\ 8\ \0\ \0\ \9\0T\ \11€\16\11\0\0007\ \5\0\16\12\7\0\20\13\0\8>\ \4\0027\ \6\ 8\ \0\ \0\ \9\0T\ \2€)\ \1\0T\11\1€)\ \2\0\15\0\ \0T\11\13€'\11\0\0'\12\2\0'\13\1\0I\11\9€\16\16\2\0007\15\5\2\16\17\7\0\16\18\8\0>\15\4\0027\15\6\15'\16\1\0009\16\14\15K\11÷\127A\7\3\3N\7½\127H\2\2\0\1À\8rgb\7at\11pixels\ floor\9math\12RGB2YIQ\ clone\2À\1\0\3\7\3\0\4%+\3\0\0>\3\1\2+\4\1\0\28\4\0\4\1\3\4\0T\3\26€+\3\2\0\ \3\0\0T\3\5€+\3\2\0+\4\2\0+\5\2\0F\3\4\0T\3\22€\27\3\1\0\27\4\2\1\30\3\4\3\27\4\3\2\30\3\4\3'\4€\0\1\3\4\0T\4\5€'\4ÿ\0'\5ÿ\0'\6ÿ\0F\4\4\0T\4\9€'\4\0\0'\5\0\0'\6\0\0F\4\4\0T\3\4€\16\3\0\0\16\4\1\0\16\5\2\0F\3\4\0G\0\1\0\3À\1À\2À\2ç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3:\1\3\7\0\4\0\0074\3\0\0007\3\1\3\16\5\0\0007\4\2\0001\6\3\0000\0\0€@\4\3\0\0\14mapPixels\11random\9math\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0'\5ÿ\0@\2\4\0\15À\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0'\5\0\0@\2\4\0\15Àl\0\0\6\6\0\1\21+\0\0\0>\0\1\2+\1\0\0>\1\1\2+\2\1\0+\3\2\0\16\4\0\0>\3\2\2\27\3\0\3>\2\2\2+\3\3\0+\4\4\0 \4\1\4>\3\2\2 \3\3\2+\4\5\0+\5\4\0 \5\1\5>\4\2\2 \4\4\2F\3\3\0\ À\9À\8À\6À\2À\7Àüÿÿÿ\31±\2\0\2\20\3\6\2@\14\0\1\0T\2\1€'\1\1\0\15\0\0\0T\2\3€'\2\0\0\3\1\2\0T\2\1€H\0\2\0007\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0'\4\0\0\21\5\0\2'\6\1\0I\4(€'\8\0\0\21\9\1\3'\ \2\0I\8#€+\12\1\0>\12\1\3\16\15\0\0007\14\3\0\16\16\7\0\16\17\11\0>\14\4\2+\15\2\0\16\17\0\0007\16\3\0\16\18\7\0\16\19\11\0>\16\4\0027\16\4\16 \17\1\12\30\16\17\16>\15\2\2:\15\4\14\16\15\0\0007\14\3\0\16\16\7\0\20\17\0\11>\14\4\2+\15\2\0\16\17\0\0007\16\3\0\16\18\7\0\20\19\0\11>\16\4\0027\16\4\16 \17\1\13\30\16\17\16>\15\2\2:\15\4\14K\8Ý\127K\4Ø\127+\4\0\0007\4\5\4\16\5\0\0@\4\2\0\1À\18À\11À\12YIQ2RGB\6y\7at\12RGB2YIQ\ width\11height\2\4Ö\2\3\0\21\0\30\1,4\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\2\27\2\0\0024\3\3\0007\3\5\0034\4\3\0007\4\6\0044\5\3\0007\5\7\0054\6\3\0007\6\8\0064\7\3\0007\7\9\0074\8\3\0007\8\ \0084\9\3\0007\9\11\0094\ \3\0007\ \12\ 1\11\13\0001\12\14\0001\13\15\0001\14\16\0001\15\17\0001\16\18\0001\17\19\0001\18\20\0001\19\21\0003\20\22\0:\12\23\20:\13\24\20:\14\25\20:\15\26\20:\16\27\20:\17\28\20:\19\29\0200\0\0€H\20\2\0\18gaussianNoise\15blackNoise\15whiteNoise\17impulseNoise\16addContours\13contours\11emboss\1\0\0\0\0\0\0\0\0\0\0\0\11random\9sqrt\8log\8sin\8cos\8max\8min\ floor\7pi\9math\13il.color\ image\12require\4\0" ) package.preload["il.morph"] = load( "\27LJ\1\2ß\4\0\3\29\0\9\2Š\0017\3\0\0007\4\1\0\15\0\1\0T\5\6€4\5\2\0007\5\3\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\2\0007\5\4\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0\15\0\2\0T\5\4€4\5\2\0007\5\4\5\14\0\5\0T\6\2€4\5\2\0007\5\5\5\16\7\0\0007\6\6\0>\6\2\2\16\8\0\0007\7\6\0>\7\2\0024\8\2\0007\8\4\0084\9\2\0007\9\5\9'\ \0\0\21\11\1\3'\12\1\0I\ /€\16\14\1\0\31\15\1\4\21\15\1\15'\16\1\0I\14)€\15\0\2\0T\18\2€'\18\0\0T\19\1€'\18ÿ\0\18\19\1\0\16\20\1\0'\21\1\0I\19\12€\16\23\5\0\16\24\18\0\16\26\0\0007\25\7\0\16\27\13\0\30\28\22\17>\25\4\0027\25\8\0258\25\0\25>\23\3\2\16\18\23\0K\19ô\127\16\20\6\0007\19\7\6\16\21\13\0\16\22\17\0>\19\4\0027\19\8\19\15\0\2\0T\20\6€\16\20\9\0\20\21\1\18'\22ÿ\0>\20\3\2\14\0\20\0T\21\4€\16\20\8\0\21\21\1\18'\22\0\0>\20\3\2;\20\0\19K\14×\127K\ Ñ\127'\ \0\0\21\11\1\4'\12\1\0I\ /€\16\14\1\0\31\15\1\3\21\15\1\15'\16\1\0I\14)€\15\0\2\0T\18\2€'\18\0\0T\19\1€'\18ÿ\0\18\19\1\0\16\20\1\0'\21\1\0I\19\12€\16\23\5\0\16\24\18\0\16\26\6\0007\25\7\6\30\27\22\17\16\28\13\0>\25\4\0027\25\8\0258\25\0\25>\23\3\2\16\18\23\0K\19ô\127\16\20\7\0007\19\7\7\16\21\17\0\16\22\13\0>\19\4\0027\19\8\19\15\0\2\0T\20\6€\16\20\9\0\20\21\1\18'\22ÿ\0>\20\3\2\14\0\20\0T\21\4€\16\20\8\0\21\21\1\18'\22\0\0>\20\3\2;\20\0\19K\14×\127K\ Ñ\127H\7\2\0\8rgb\7at\ clone\8min\8max\ floor\9math\ width\11height\4\2\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\1\0@\2\4\0\1À\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\2\0@\2\4\0\1À¥\5\0\2\22\0\8\2\0017\2\0\0007\3\1\0\16\5\0\0007\4\2\0>\4\2\0024\5\3\0007\5\4\0054\6\3\0007\6\5\6\15\0\1\0T\7I€'\7\1\0\21\8\0\2'\9\1\0I\7D€'\11\1\0\21\12\0\3'\13\1\0I\11?€\16\16\0\0007\15\6\0\16\17\ \0\16\18\14\0>\15\4\0027\15\7\0158\15\0\15\16\16\5\0\16\17\15\0\16\19\0\0007\18\6\0\20\20\1\ \16\21\14\0>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\5\0\16\17\15\0\16\19\0\0007\18\6\0\21\20\1\ \16\21\14\0>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\5\0\16\17\15\0\16\19\0\0007\18\6\0\16\20\ \0\20\21\1\14>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\5\0\16\17\15\0\16\19\0\0007\18\6\0\16\20\ \0\21\21\1\14>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\17\4\0007\16\6\4\16\18\ \0\16\19\14\0>\16\4\0027\16\7\16\16\17\6\0\20\18\1\15'\19ÿ\0>\17\3\2;\17\0\16K\11Á\127K\7¼\127T\7H€'\7\1\0\21\8\0\2'\9\1\0I\7D€'\11\1\0\21\12\0\3'\13\1\0I\11?€\16\16\0\0007\15\6\0\16\17\ \0\16\18\14\0>\15\4\0027\15\7\0158\15\0\15\16\16\6\0\16\17\15\0\16\19\0\0007\18\6\0\20\20\1\ \16\21\14\0>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\6\0\16\17\15\0\16\19\0\0007\18\6\0\21\20\1\ \16\21\14\0>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\6\0\16\17\15\0\16\19\0\0007\18\6\0\16\20\ \0\20\21\1\14>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\16\6\0\16\17\15\0\16\19\0\0007\18\6\0\16\20\ \0\21\21\1\14>\18\4\0027\18\7\0188\18\0\18>\16\3\2\16\15\16\0\16\17\4\0007\16\6\4\16\18\ \0\16\19\14\0>\16\4\0027\16\7\16\16\17\5\0\21\18\1\15'\19\0\0>\17\3\2;\17\0\16K\11Á\127K\7¼\127H\4\2\0\8rgb\7at\8min\8max\9math\ clone\ width\11height\4\2‰\1\0\3\8\3\2\0\27+\3\0\0007\3\0\3\16\4\0\0>\3\2\2\16\0\3\0\15\0\1\0T\3\12€'\3\1\0\1\3\1\0T\3\9€+\3\0\0007\3\1\3+\4\1\0\16\5\0\0\16\6\1\0\16\7\2\0>\4\4\0?\3\0\0T\3\7€+\3\0\0007\3\1\3+\4\2\0\16\5\0\0\16\6\2\0>\4\3\0?\3\0\0G\0\1\0\0À\1À\4À\12YIQ2RGB\12RGB2YIQ\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\1\0@\2\4\0\5À\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\2\0@\2\4\0\5ÀÎ\2\0\2\30\0\9\2F7\2\0\0007\3\1\0\16\5\0\0007\4\2\0>\4\2\2\15\0\1\0T\5\6€4\5\3\0007\5\4\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\3\0007\5\5\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0004\5\3\0007\5\5\0054\6\3\0007\6\6\6\16\7\1\0\31\8\1\2\21\8\1\8'\9\1\0I\7(€\16\11\1\0\31\12\1\3\21\12\1\12'\13\1\0I\11\"€'\15ÿ\0\18\16\1\0\16\17\1\0'\18\1\0I\16\17€\18\20\1\0\16\21\1\0'\22\1\0I\20\12€\16\24\6\0\16\25\15\0\16\27\0\0007\26\7\0\30\28\19\ \30\29\23\14>\26\4\0027\26\8\0268\26\0\26>\24\3\2\16\15\24\0K\20ô\127K\16ï\127\16\17\4\0007\16\7\4\16\18\ \0\16\19\14\0>\16\4\0027\16\8\16\16\17\5\0\21\18\1\15'\19\0\0>\17\3\2;\17\0\16K\11Þ\127K\7Ø\127H\4\2\0\8rgb\7at\8min\8max\ floor\9math\ clone\ width\11height\4\2Î\2\0\2\30\0\9\2F7\2\0\0007\3\1\0\16\5\0\0007\4\2\0>\4\2\2\15\0\1\0T\5\6€4\5\3\0007\5\4\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\3\0007\5\5\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0004\5\3\0007\5\5\0054\6\3\0007\6\6\6\16\7\1\0\31\8\1\2\21\8\1\8'\9\1\0I\7(€\16\11\1\0\31\12\1\3\21\12\1\12'\13\1\0I\11\"€'\15\0\0\18\16\1\0\16\17\1\0'\18\1\0I\16\17€\18\20\1\0\16\21\1\0'\22\1\0I\20\12€\16\24\5\0\16\25\15\0\16\27\0\0007\26\7\0\30\28\19\ \30\29\23\14>\26\4\0027\26\8\0268\26\0\26>\24\3\2\16\15\24\0K\20ô\127K\16ï\127\16\17\4\0007\16\7\4\16\18\ \0\16\19\14\0>\16\4\0027\16\8\16\16\17\6\0\20\18\1\15'\19ÿ\0>\17\3\2;\17\0\16K\11Þ\127K\7Ø\127H\4\2\0\8rgb\7at\8min\8max\ floor\9math\ clone\ width\11height\4\2i\0\2\5\3\2\0\19+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\0\0007\2\1\2\16\3\0\0@\2\2\0\0À\2À\3À\12YIQ2RGB\12RGB2YIQi\0\2\5\3\2\0\19+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\0\0007\2\1\2\16\3\0\0@\2\2\0\0À\3À\2À\12YIQ2RGB\12RGB2YIQ‘\1\0\2\5\3\2\0\29+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\0\0007\2\1\2\16\3\0\0@\2\2\0\0À\2À\3À\12YIQ2RGB\12RGB2YIQ‘\1\0\2\5\3\2\0\29+\2\0\0007\2\0\2\16\3\0\0>\2\2\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\2\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\1\0\16\3\0\0\16\4\1\0>\2\3\2\16\0\2\0+\2\0\0007\2\1\2\16\3\0\0@\2\2\0\0À\3À\2À\12YIQ2RGB\12RGB2YIQÝ\1\3\0\15\0\24\0\0274\0\0\0%\1\1\0>\0\2\0021\1\2\0001\2\3\0001\3\4\0001\4\5\0001\5\6\0001\6\7\0001\7\8\0001\8\9\0001\9\ \0001\ \11\0001\11\12\0001\12\13\0001\13\14\0003\14\15\0:\3\16\14:\2\17\14:\7\18\14:\6\19\14:\ \20\14:\11\21\14:\12\22\14:\13\23\0140\0\0€H\14\2\0\13smoothCO\13smoothOC\ close\9open\ erode\11dilate\19erodeIntensity\20dilateIntensity\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\13il.color\12require\0" ) package.preload["il.point"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\1À\1€€€ÿ\3'\0\1\5\2\0\0\7+\1\0\0+\2\1\0\16\3\0\0'\4\0\0>\2\3\2'\3ÿ\0@\1\3\0\3À\4À1\0\3\7\1\0\0\ +\3\0\0\16\4\0\0>\3\2\2+\4\0\0\16\5\1\0>\4\2\2+\5\0\0\16\6\2\0>\5\2\0E\3\2\0\1À!\0\3\6\1\0\0\6+\3\0\0\16\4\0\0>\3\2\2\16\4\1\0\16\5\2\0F\3\4\0\1Àá\1\1\3\6\1\9\0)\7\2\0\0T\3\6€\16\4\0\0007\3\1\0001\5\2\0000\0\0€@\3\3\0T\3\13€\7\2\3\0T\3\6€+\3\0\0007\3\4\3\16\4\0\0>\3\2\2\16\0\3\0T\3\5€+\3\0\0007\3\5\3\16\4\0\0>\3\2\2\16\0\3\0\16\4\0\0007\3\1\0001\5\6\0>\3\3\2\16\0\3\0\7\2\3\0T\3\6€+\3\0\0007\3\7\3\16\4\0\0000\0\0€@\3\2\0T\3\5€+\3\0\0007\3\8\3\16\4\0\0000\0\0€@\3\2\0000\0\0€G\0\1\0\0À\12YIQ2RGB\12IHS2RGB\0\12RGB2YIQ\12RGB2IHS\8ihs\0\14mapPixels\8rgb\17\0\1\2\0\0\1\2\26\1\0\0H\1\2\0þ\3\"\1\2\6\1\1\0\6+\2\0\0\16\3\0\0001\4\0\0\16\5\1\0000\0\0€@\2\4\0\6À\0\21\0\1\2\1\0\0\3+\1\0\0006\1\0\1H\1\2\0\3ÀV\1\3\11\3\1\0\0182\3\0\0'\4\0\0'\5ÿ\0'\6\1\0I\4\7€+\8\0\0+\9\1\0\30\ \1\7>\9\2\0=\8\0\0029\8\7\3K\4ù\127+\4\2\0\16\5\0\0001\6\0\0\16\7\2\0000\0\0€@\4\4\0\2À\5À\6À\0\21\0\1\2\1\0\0\3+\1\0\0006\1\0\1H\1\2\0\3ÀV\1\3\ \2\1\1\0182\3\0\0'\4\0\0'\5ÿ\0'\6\1\0I\4\7€+\8\0\0\23\9\0\7#\9\1\9\27\9\0\9>\8\2\0029\8\7\3K\4ù\127+\4\1\0\16\5\0\0001\6\0\0\16\7\2\0000\0\0€@\4\4\0\2À\6À\0þ\3\21\0\1\2\1\0\0\3+\1\0\0006\1\0\1H\1\2\0\4À|\1\2\12\2\3\2\0254\2\0\0007\2\1\2\16\3\2\0'\4\0\1>\3\2\2\28\3\0\0032\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\8€+\9\0\0\16\ \2\0\20\11\1\8>\ \2\2 \ \ \3>\9\2\0029\9\8\4K\5ø\127+\5\1\0\16\6\0\0001\7\2\0\16\8\1\0000\0\0€@\5\4\0\2À\6À\0\8log\9mathþ\3\2\21\0\1\2\1\0\0\3+\1\0\0006\1\0\1H\1\2\0\5À•\1\1\3\13\3\1\2!'\3\1\0\0\1\3\0T\3\3€'\3\0\1\1\3\1\0T\3\1€0\0\25€\23\3\0\1\21\4\1\1\28\4\0\0042\5\0\0'\6\0\0'\7ÿ\0'\8\1\0I\6\11€+\ \0\0+\11\0\0 \12\3\9>\11\2\2 \11\4\11>\ \2\2+\11\1\0\16\12\ \0>\11\2\0029\11\9\5K\6õ\127+\6\2\0\16\7\0\0001\8\0\0\16\9\2\0000\0\0€@\6\4\0H\0\2\0\1À\5À\6À\0þ\3\2.\0\3\7\1\0\1\9+\3\0\0\30\4\1\0\30\4\2\4\23\4\0\4>\3\2\2\16\4\3\0\16\5\3\0\16\6\3\0F\4\4\0\0\0\6S\0\3\7\1\0\3\11+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2\16\4\3\0\16\5\3\0\16\6\3\0F\4\4\0\0\0ç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3Q\1\2\5\1\4\0\14\7\1\0\0T\2\6€\16\3\0\0007\2\1\0001\4\2\0000\0\0€@\2\3\0T\2\5€\16\3\0\0007\2\1\0001\4\3\0000\0\0€@\2\3\0G\0\1\0\2À\0\0\14mapPixels\8ihs\29\0\1\4\1\1\0\4+\1\0\0\16\2\0\0%\3\0\0@\1\3\0\12À\8ihs\29\0\1\4\1\1\0\4+\1\0\0\16\2\0\0%\3\0\0@\1\3\0\12À\8yiq\25\0\3\6\0\0\1\4\26\3\0\0\26\4\0\1\26\5\0\2F\3\4\0þ\3\25\0\3\6\0\0\1\4\26\3\0\0\16\4\1\0\16\5\2\0F\3\4\0þ\3Ý\1\1\2\5\1\9\0(\7\1\0\0T\2\6€\16\3\0\0007\2\1\0001\4\2\0000\0\0€@\2\3\0T\2\13€\7\1\3\0T\2\6€+\2\0\0007\2\4\2\16\3\0\0>\2\2\2\16\0\2\0T\2\5€+\2\0\0007\2\5\2\16\3\0\0>\2\2\2\16\0\2\0\16\3\0\0007\2\1\0001\4\6\0>\2\3\2\16\0\2\0\7\1\3\0T\2\6€+\2\0\0007\2\7\2\16\3\0\0000\0\0€@\2\2\0T\2\5€+\2\0\0007\2\8\2\16\3\0\0000\0\0€@\2\2\0G\0\1\0\0À\12YIQ2RGB\12IHS2RGB\0\12RGB2YIQ\12RGB2IHS\8ihs\0\14mapPixels\8rgb%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\5Àß\3\1\3\16\3\11\2d'\3\1\0\0\1\3\0T\3\3€'\3\0\1\1\3\1\0T\3\1€0\0\\€\7\2\0\0T\3\25€\23\3\0\1\21\4\1\1\28\4\0\0042\5\0\0'\6\0\0'\7ÿ\0'\8\1\0I\6\11€+\ \0\0+\11\0\0 \12\3\9>\11\2\2 \11\4\11>\ \2\2+\11\1\0\16\12\ \0>\11\2\0029\11\9\5K\6õ\127\16\7\0\0007\6\1\0001\8\2\0000\0\0€@\6\3\0000\3\13€\7\2\3\0T\3\6€+\3\2\0007\3\4\3\16\4\0\0>\3\2\2\16\0\3\0T\3\5€+\3\2\0007\3\5\3\16\4\0\0>\3\2\2\16\0\3\0\23\3\0\1\21\4\1\1\28\4\0\0042\5\0\0'\6\0\0'\7ÿ\0'\8\1\0I\6\11€+\ \0\0+\11\0\0 \12\3\9>\11\2\2 \11\4\11>\ \2\2+\11\1\0\16\12\ \0>\11\2\0029\11\9\5K\6õ\127\16\7\0\0007\6\6\0>\6\2\4T\9\13€\16\12\0\0007\11\7\0\16\13\9\0\16\14\ \0>\11\4\2\16\13\0\0007\12\7\0\16\14\9\0\16\15\ \0>\12\4\0027\12\8\0126\12\12\5:\12\8\11A\9\3\3N\9ñ\127\7\2\3\0T\6\6€+\6\2\0007\6\9\6\16\7\0\0000\0\0€@\6\2\0T\6\5€+\6\2\0007\6\ \6\16\7\0\0000\0\0€@\6\2\0G\0\1\0H\0\2\0\1À\5À\0À\12YIQ2RGB\12IHS2RGB\6y\7at\11pixels\12RGB2YIQ\12RGB2IHS\8ihs\0\14mapPixels\8rgbþ\3\2!\0\3\7\1\1\0\5+\3\0\0\16\4\0\0\16\5\1\0%\6\0\0@\3\4\0\11À\8yiq!\0\3\7\1\1\0\5+\3\0\0\16\4\0\0\16\5\1\0%\6\0\0@\3\4\0\11À\8ihs!\0\3\7\1\1\0\5+\3\0\0\16\4\0\0\16\5\1\0%\6\0\0@\3\4\0\11À\8rgb%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\2À†\1\1\2\9\1\2\1\28'\2\1\0\0\1\2\0T\2\3€'\2\0\1\1\2\1\0T\2\1€0\0\20€+\2\0\0\28\3\0\1>\2\2\2\16\1\2\0002\2\0\0'\3\0\0'\4ÿ\0'\5\1\0I\3\6€+\7\0\0!\8\1\6>\7\2\2 \7\1\0079\7\6\2K\3ú\127\16\4\0\0007\3\0\0001\5\1\0000\0\0€@\3\3\0H\0\2\0\1À\0\14mapPixels€\4%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\4Àž\1\1\3\11\1\2\1\"'\3\0\0\0\1\3\0T\3\11€'\3ÿ\0\0\3\1\0T\3\8€'\3\0\0\0\2\3\0T\3\5€'\3ÿ\0\0\3\2\0T\3\2€\3\2\1\0T\3\1€0\0\18€\31\3\1\2\23\3\0\0032\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\6€+\9\0\0 \ \3\8\30\ \1\ >\9\2\0029\9\8\4K\5ú\127\16\6\0\0007\5\0\0001\7\1\0000\0\0€@\5\3\0H\0\2\0\2À\0\14mapPixelsþ\3Á\2\0\3\15\2\5\1F'\3\0\0\0\1\3\0T\3\11€'\3ÿ\0\0\3\1\0T\3\8€'\3\0\0\0\2\3\0T\3\5€'\3ÿ\0\0\3\2\0T\3\2€\3\2\1\0T\3\1€H\0\2\0+\3\0\0007\3\0\3\16\4\0\0>\3\2\2\16\0\3\0\31\3\1\2\28\3\0\0032\4\0\0'\5\0\0\16\6\1\0'\7\1\0I\5\3€'\9\0\0009\9\8\4K\5ý\127\16\5\2\0'\6ÿ\0'\7\1\0I\5\3€'\9ÿ\0009\9\8\4K\5ý\127\16\5\1\0\16\6\2\0'\7\1\0I\5\6€+\9\1\0\31\ \1\8 \ \ \3>\9\2\0029\9\8\4K\5ú\127\16\6\0\0007\5\1\0>\5\2\4T\8\13€\16\11\0\0007\ \2\0\16\12\8\0\16\13\9\0>\ \4\2\16\12\0\0007\11\2\0\16\13\8\0\16\14\9\0>\11\4\0027\11\3\0116\11\11\4:\11\3\ A\8\3\3N\8ñ\127+\5\0\0007\5\4\5\16\6\0\0@\5\2\0\0À\2À\12YIQ2RGB\6y\7at\11pixels\12RGB2YIQþ\3%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\2À_\1\2\12\0\2\1\0192\2\0\0'\3\0\0'\4\0\0\21\5\0\1'\6\1\0I\4\8€'\8\0\0'\9ÿ\0\16\ \1\0I\8\3€9\11\3\2\20\3\0\3K\8ý\127K\4ø\127\16\5\0\0007\4\0\0001\6\1\0000\0\0€@\4\3\0\0\14mapPixels\2%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\3À\29\0\3\6\1\0\0\5+\3\0\0006\3\0\3\16\4\1\0\16\5\2\0F\3\4\0\3À•\2\1\3\ \2\9\00152\3\0\0'\4\0\0'\5ÿ\0'\6\1\0I\4\7€+\8\0\0\23\9\0\7#\9\1\9\27\9\0\9>\8\2\0029\8\7\3K\4ù\127\7\2\0\0T\4\6€\16\5\0\0007\4\1\0001\6\2\0000\0\0€@\4\3\0T\4\13€\7\2\3\0T\4\6€+\4\1\0007\4\4\4\16\5\0\0>\4\2\2\16\0\4\0T\4\5€+\4\1\0007\4\5\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\1\0001\6\6\0>\4\3\2\16\0\4\0\7\2\3\0T\4\6€+\4\1\0007\4\7\4\16\5\0\0000\0\0€@\4\2\0T\4\5€+\4\1\0007\4\8\4\16\5\0\0000\0\0€@\4\2\0000\0\0€G\0\1\0\2À\0À\12YIQ2RGB\12IHS2RGB\0\12RGB2YIQ\12RGB2IHS\8ihs\0\14mapPixels\8rgbþ\3%\0\3\6\1\0\0\7+\3\0\0006\3\0\3+\4\0\0006\4\1\4+\5\0\0006\5\2\5F\3\4\0\4À€\1\1\2\12\1\4\2\0244\2\0\0007\2\1\2\16\3\2\0'\4\0\1>\3\2\2\28\3\0\0032\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\8€+\9\0\0\16\ \2\0\20\11\1\8>\ \2\2 \ \ \3>\9\2\0029\9\8\4K\5ø\127\16\6\0\0007\5\2\0001\7\3\0000\0\0€@\5\3\0\2À\0\14mapPixels\8log\9mathþ\3\2u\0\3\7\1\0\4\19+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2'\4€\0\1\3\4\0T\4\5€\26\4\3\0\26\5\3\1\26\2\3\2\16\1\5\0\16\0\4\0\16\4\0\0\16\5\1\0\16\6\2\0F\4\4\0\0\0ç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3þ\3(\1\1\4\1\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\2À\0\14mapPixelsh\0\3\7\0\0\5\16\27\3\0\0\27\4\1\1\30\3\4\3\27\4\2\2\30\3\4\3\26\4\3\3'\5€\0\1\3\5\0T\5\3€\27\5\4\3\14\0\5\0T\6\2€\26\5\3\3\27\5\4\5\16\6\3\0F\4\4\0ç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3þ\3\4&\1\1\4\0\2\0\5\16\2\0\0007\1\0\0001\3\1\0000\0\0€@\1\3\0\0\14mapPixelsm\0\3\7\2\0\3\17+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2+\4\1\0006\4\3\0048\4\1\4+\5\1\0006\5\3\0058\5\2\5+\6\1\0006\6\3\0068\6\3\6F\4\4\0\0\0\1Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3å\2\1\1\7\1\ \0>2\1\0\0'\2\0\0'\3\31\0'\4\1\0I\2\3€3\6\0\0009\6\5\1K\2ý\127'\2 \0'\3?\0'\4\1\0I\2\3€3\6\1\0009\6\5\1K\2ý\127'\2@\0'\3_\0'\4\1\0I\2\3€3\6\2\0009\6\5\1K\2ý\127'\2`\0'\3\127\0'\4\1\0I\2\3€3\6\3\0009\6\5\1K\2ý\127'\2€\0'\3Ÿ\0'\4\1\0I\2\3€3\6\4\0009\6\5\1K\2ý\127'\2 \0'\3¿\0'\4\1\0I\2\3€3\6\5\0009\6\5\1K\2ý\127'\2À\0'\3ß\0'\4\1\0I\2\3€3\6\6\0009\6\5\1K\2ý\127'\2à\0'\3ÿ\0'\4\1\0I\2\3€3\6\7\0009\6\5\1K\2ý\127\16\3\0\0007\2\8\0001\4\9\0000\0\0€@\2\3\0\2À\0\14mapPixels\1\4\0\0\3ÿ\1\3ÿ\1\3ÿ\1\1\4\0\0\3ÿ\1\3\0\3\0\1\4\0\0\3ÿ\1\3\127\3\0\1\4\0\0\3ÿ\1\3ÿ\1\3\0\1\4\0\0\3\0\3ÿ\1\3\0\1\4\0\0\3\0\3\0\3ÿ\1\1\4\0\0\3\127\3\0\3\127\1\4\0\0\3\0\3\0\3\0m\0\3\7\2\0\3\17+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2+\4\1\0006\4\3\0048\4\1\4+\5\1\0006\5\3\0058\5\2\5+\6\1\0006\6\3\0068\6\3\6F\4\4\0\0\0\1Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3ö\3\1\1\9\1\ \8a2\1\0\0'\2\0\0'\3$\0'\4\1\0I\2\6€3\6\0\0\27\7\0\5\23\7\1\7;\7\3\0069\6\5\1K\2ú\127'\2\0\0'\3$\0'\4\1\0I\2\8€\20\6\1\5\20\6\2\0063\7\1\0\27\8\0\5\23\8\1\8;\8\2\0079\7\6\1K\2ø\127'\2\0\0'\3$\0'\4\1\0I\2\9€\20\6\3\5\20\6\2\0063\7\2\0\26\8\1\5\27\8\0\8\23\8\1\8;\8\3\0079\7\6\1K\2÷\127'\2\0\0'\3$\0'\4\1\0I\2\8€\20\6\4\5\20\6\2\0063\7\3\0\27\8\0\5\23\8\1\8;\8\1\0079\7\6\1K\2ø\127'\2\0\0'\3$\0'\4\1\0I\2\9€\20\6\5\5\20\6\2\0063\7\4\0\26\8\1\5\27\8\0\8\23\8\1\8;\8\2\0079\7\6\1K\2÷\127'\2\0\0'\3$\0'\4\1\0I\2\8€\20\6\6\5\20\6\2\0063\7\5\0\27\8\0\5\23\8\1\8;\8\3\0079\7\6\1K\2ø\127'\2\0\0'\3$\0'\4\1\0I\2\8€\20\6\7\5\20\6\2\0063\7\6\0\27\8\0\5\23\8\1\8;\8\2\0079\7\6\1K\2ø\127'\2þ\0'\3ÿ\0'\4\1\0I\2\3€3\6\7\0009\6\5\1K\2ý\127\16\3\0\0007\2\8\0001\4\9\0000\0\0€@\2\3\0\2À\0\14mapPixels\1\4\0\0\3ÿ\1\3ÿ\1\3ÿ\1\1\4\0\0\3ÿ\1\0\3ÿ\1\1\3\0\0\3ÿ\1\3\0\1\4\0\0\3ÿ\1\0\3\0\1\4\0\0\0\3ÿ\1\3\0\1\3\0\0\3\0\3ÿ\1\1\4\0\0\3\0\0\3ÿ\1\1\3\0\0\3\0\3\0þ\3H\2\1Ø\1 \2è\2°\3m\0\3\7\2\0\3\17+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2+\4\1\0006\4\3\0048\4\1\4+\5\1\0006\5\3\0058\5\2\5+\6\1\0006\6\3\0068\6\3\6F\4\4\0\0\0\3Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3Û\1\1\2\11\1\6\2'4\2\0\0007\2\1\0022\3\0\0'\4\0\0'\5ÿ\0'\6\1\0I\4\21€2\8\4\0+\9\0\0\16\ \2\0>\ \1\2\27\ \0\ >\9\2\2;\9\1\8+\9\0\0\16\ \2\0>\ \1\2\27\ \0\ >\9\2\2;\9\2\8+\9\0\0\16\ \2\0>\ \1\2\27\ \0\ >\9\2\0<\9\1\0009\8\7\3K\4ë\127\14\0\1\0T\4\4€3\4\2\0;\4\0\0033\4\3\0;\4ÿ\3\16\5\0\0007\4\4\0001\6\5\0000\0\0€@\4\3\0\2À\0\14mapPixels\1\4\0\0\3ÿ\1\3ÿ\1\3ÿ\1\1\4\0\0\3\0\3\0\3\0\11random\9mathþ\3\7€€À™\4m\0\3\7\2\0\3\17+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2+\4\1\0006\4\3\0048\4\1\4+\5\1\0006\5\3\0058\5\2\5+\6\1\0006\6\3\0068\6\3\6F\4\4\0\0\0\2Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3Ž\2\1\2\19\1\4\3;2\2\0\0'\3\0\0'\4\7\0'\5\1\0I\0031€\22\7\0\6'\8\0\0'\9\31\0'\ \1\0I\8+€\22\12\1\11'\13\0\0'\14\0\0'\15\0\0004\16\0\0007\16\1\16\16\17\6\0'\18\1\0>\16\3\2\8\16\2\0T\16\1€\16\13\12\0004\16\0\0007\16\1\16\16\17\6\0'\18\2\0>\16\3\2\8\16\2\0T\16\1€\16\14\12\0004\16\0\0007\16\1\16\16\17\6\0'\18\4\0>\16\3\2\8\16\2\0T\16\1€\16\15\12\0\30\16\11\7\15\0\1\0T\17\6€2\17\4\0;\13\1\17;\14\2\17;\15\3\17\14\0\17\0T\18\4€2\17\4\0;\15\1\17;\14\2\17;\13\3\0179\17\16\2K\8Õ\127K\3Ï\127\16\4\0\0007\3\2\0001\5\3\0000\0\0€@\3\3\0\2À\0\14mapPixels\9band\ bit32@\16\0\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\2\0@\1\3\0\31À\25\0\1\4\1\0\0\4+\1\0\0\16\2\0\0)\3\1\0@\1\3\0\31Àa\0\3\7\2\0\3\14+\3\0\0\27\4\0\0\27\5\1\1\30\4\5\4\27\5\2\2\30\4\5\4>\3\2\2+\4\1\0006\4\3\4+\5\1\0006\5\3\5+\6\1\0006\6\3\6F\4\4\0\0\0\4Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3¨\1\1\2\13\1\5\1 '\2\0\0\0\1\2\0T\2\3€'\2\7\0\1\2\1\0T\2\1€0\0\24€4\2\0\0007\2\1\0024\3\0\0007\3\2\0032\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\ €\16\9\2\0\16\ \3\0\16\11\8\0\16\12\1\0>\ \3\2'\11\1\0>\9\3\2\22\9\0\0099\9\8\4K\5ö\127\16\6\0\0007\5\3\0001\7\4\0000\0\0€@\5\3\0H\0\2\0\2À\0\14mapPixels\11rshift\9band\ bit32þ\3\29\0\3\6\3\0\0\4+\3\0\0+\4\1\0+\5\2\0F\3\4\0\2À\3À\4ÀY\1\2\8\0\5\0\14\16\3\1\0007\2\0\1>\2\2\2\16\4\1\0007\3\1\1>\3\2\2\16\5\1\0007\4\2\1>\4\2\2\16\6\0\0007\5\3\0001\7\4\0000\0\0€@\5\3\0\0\14mapPixels\9Blue\ Green\8Redå\4\3\0%\0?\0D4\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0011\2\4\0004\3\2\0007\3\5\0034\4\2\0007\4\6\0041\5\7\0001\6\8\0001\7\9\0001\8\ \0001\9\11\0001\ \12\0001\11\13\0001\12\14\0001\13\15\0001\14\16\0001\15\17\0001\16\18\0001\17\19\0001\18\20\0001\19\21\0001\20\22\0001\21\23\0001\22\24\0001\23\25\0001\24\26\0001\25\27\0001\26\28\0001\27\29\0001\28\30\0001\29\31\0001\30 \0001\31!\0001 \"\0001!#\0001\"$\0001#%\0003$&\0:\12'$:\13($:\14)$:\7*$:\8+$:\9,$:\ -$:\11.$:\19/$:\0170$:\0181$:\0202$:\0213$:\0224$:\0265$:\0276$:\0287$:\0298$:\0309$: :$:!;$:\23<$:\"=$:#>$0\0\0€H$\2\0\9fill\ slice\13sawtooth\16sawtoothBGR\16sawtoothRGB\17pseudocolor4\17pseudocolor3\17pseudocolor2\17pseudocolor1\13solarize\20contrastStretch\21scaleIntensities\13quantize\17posterizeIHS\17posterizeYIQ\17posterizeRGB\14posterize\13logscale\ gamma\13brighten\11negate\17grayscaleYIQ\17grayscaleIHS\14grayscale\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\8max\8min\0\ floor\9math\13il.color\12require\0" ) package.preload["il.rotate"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\6À\1€€€ÿ\3)\0\2\4\0\2\0\0064\2\0\0 \2\2\0004\3\1\0 \3\3\1\31\2\3\2H\2\2\0\9sin0\9cos0)\0\2\4\0\2\0\0064\2\0\0 \2\2\0004\3\1\0 \3\3\1\30\2\3\2H\2\2\0\9cos0\9sin0Â\15\0\3'\ \16\5Ð\3\15\0\2\0T\3\6€4\3\0\0007\3\1\3\16\4\2\0>\3\2\2\12\2\3\0T\4\1€%\2\2\0\6\2\3\0T\3\7€\6\2\4\0T\3\5€\6\2\2\0T\3\3€\6\2\5\0T\3\1€H\0\2\0\23\3\0\1+\4\0\0\23\5\0\1>\4\2\2\31\3\4\3(\4\1\0\1\3\4\0T\3\1€H\0\2\0+\3\1\0+\4\2\0 \4\4\1\23\4\2\4>\3\2\0025\3\6\0+\3\3\0+\4\2\0 \4\4\1\23\4\2\4>\3\2\0025\3\7\0007\3\8\0007\4\9\0+\5\4\0'\6\0\0'\7\0\0>\5\3\2+\6\5\0'\7\0\0'\8\0\0>\6\3\2\16\7\5\0\16\8\6\0+\9\4\0\16\ \4\0'\11\0\0>\9\3\2+\ \5\0\16\11\4\0'\12\0\0>\ \3\2+\11\6\0\16\12\9\0\16\13\5\0>\11\3\2\16\5\11\0+\11\6\0\16\12\ \0\16\13\6\0>\11\3\2\16\6\11\0+\11\7\0\16\12\9\0\16\13\7\0>\11\3\2\16\7\11\0+\11\7\0\16\12\ \0\16\13\8\0>\11\3\2\16\8\11\0+\11\4\0'\12\0\0\16\13\3\0>\11\3\2+\12\5\0'\13\0\0\16\14\3\0>\12\3\2\16\ \12\0\16\9\11\0+\11\6\0\16\12\9\0\16\13\5\0>\11\3\2\16\5\11\0+\11\6\0\16\12\ \0\16\13\6\0>\11\3\2\16\6\11\0+\11\7\0\16\12\9\0\16\13\7\0>\11\3\2\16\7\11\0+\11\7\0\16\12\ \0\16\13\8\0>\11\3\2\16\8\11\0+\11\4\0\16\12\4\0\16\13\3\0>\11\3\2+\12\5\0\16\13\4\0\16\14\3\0>\12\3\2\16\ \12\0\16\9\11\0+\11\6\0\16\12\9\0\16\13\5\0>\11\3\2\16\5\11\0+\11\6\0\16\12\ \0\16\13\6\0>\11\3\2\16\6\11\0+\11\7\0\16\12\9\0\16\13\7\0>\11\3\2\16\7\11\0+\11\7\0\16\12\ \0\16\13\8\0>\11\3\2\16\8\11\0+\11\0\0\31\12\6\8>\11\2\2+\12\0\0\31\13\5\7>\12\2\2'\13\1\0\0\11\13\0T\13\9€'\13\0@\0\13\11\0T\13\6€'\13\1\0\0\12\13\0T\13\3€'\13\0@\1\13\12\0T\13\1€H\0\2\0\23\13\3\11\23\14\3\12\23\15\3\3\23\16\3\4+\17\8\0007\17\ \17\16\18\12\0\16\19\11\0>\17\3\2\6\2\3\0T\18\2€\7\2\4\0T\18;€'\18\0\0\21\19\4\11'\20\1\0I\0186€'\22\0\0\21\23\4\12'\24\1\0I\0221€+\26\9\0\31\27\14\0254\28\7\0 \27\28\27\31\27\27\15\31\28\13\0214\29\6\0 \28\29\28\30\27\28\27>\26\2\2+\27\9\0\31\28\14\0254\29\6\0 \28\29\28\30\28\28\16\31\29\13\0214\30\7\0 \29\30\29\30\28\29\28>\27\2\2+\28\6\0+\29\7\0\16\30\26\0'\31\0\0>\29\3\2\21\30\4\3>\28\3\2\16\26\28\0+\28\6\0+\29\7\0\16\30\27\0'\31\0\0>\29\3\2\21\30\4\4>\28\3\2\16\27\28\0\16\29\17\0007\28\11\17\16\30\21\0\16\31\25\0>\28\4\2\16\30\0\0007\29\11\0\16\31\26\0\16 \27\0>\29\4\0027\29\12\29:\29\12\28K\22Ï\127K\18Ê\127T\18é€\6\2\2\0T\18\2€\7\2\5\0T\18å€'\18\0\0\21\19\4\11'\20\1\0I\18á€'\22\0\0\21\23\4\12'\24\1\0I\22܀\31\26\14\0254\27\7\0 \26\27\26\31\26\26\15\31\27\13\0214\28\6\0 \27\28\27\30\ \27\26\31\26\14\0254\27\6\0 \26\27\26\30\26\26\16\31\27\13\0214\28\7\0 \27\28\27\30\9\27\26'\26\0\0'\27\0\0'\28\0\0\1\ \28\0T\28\2€'\ \0\0T\28\13€\21\28\4\3\3\28\ \0T\28\5€\21\ \4\3\16\28\ \0\16\27\ \0\16\26\28\0T\28\5€+\28\0\0\16\29\ \0>\28\2\2\16\26\28\0\20\27\4\26'\28\0\0'\29\0\0'\30\0\0\1\9\30\0T\30\2€'\9\0\0T\30\13€\21\30\4\4\3\30\9\0T\30\5€\21\9\4\4\16\30\9\0\16\29\9\0\16\28\30\0T\30\5€+\30\0\0\16\31\9\0>\30\2\2\16\28\30\0\20\29\4\28\31\30\28\9\16 \0\0007\31\11\0\16!\26\0\16\"\28\0>\31\4\0027\31\13\31\16!\0\0007 \11\0\16\"\26\0\16#\29\0> \4\0027 \13 \16\"\0\0007!\11\0\16#\26\0\16$\28\0>!\4\0027!\13!\31 ! \30\30\31 \31\16!\0\0007 \11\0\16\"\27\0\16#\28\0> \4\0027 \13 \16\"\0\0007!\11\0\16#\27\0\16$\29\0>!\4\0027!\13!\16#\0\0007\"\11\0\16$\27\0\16%\28\0>\"\4\0027\"\13\"\31!\"! !!\30\30 ! \16\"\17\0007!\11\17\16#\21\0\16$\25\0>!\4\2+\"\9\0\31#\26\ \31$\31 #$#\30##\31>\"\2\2:\"\13!\16\"\0\0007!\11\0\16#\26\0\16$\28\0>!\4\0027!\14!\16#\0\0007\"\11\0\16$\26\0\16%\29\0>\"\4\0027\"\14\"\16$\0\0007#\11\0\16%\26\0\16&\28\0>#\4\0027#\14#\31\"#\" \"\"\30\30\31\"!\16\"\0\0007!\11\0\16#\27\0\16$\28\0>!\4\0027!\14!\16#\0\0007\"\11\0\16$\27\0\16%\29\0>\"\4\0027\"\14\"\16$\0\0007#\11\0\16%\27\0\16&\28\0>#\4\0027#\14#\31\"#\" \"\"\30\30 \"!\16\"\17\0007!\11\17\16#\21\0\16$\25\0>!\4\2+\"\9\0\31#\26\ \31$\31 #$#\30##\31>\"\2\2:\"\14!\16\"\0\0007!\11\0\16#\26\0\16$\28\0>!\4\0027!\15!\16#\0\0007\"\11\0\16$\26\0\16%\29\0>\"\4\0027\"\15\"\16$\0\0007#\11\0\16%\26\0\16&\28\0>#\4\0027#\15#\31\"#\" \"\"\30\30\31\"!\16\"\0\0007!\11\0\16#\27\0\16$\28\0>!\4\0027!\15!\16#\0\0007\"\11\0\16$\27\0\16%\29\0>\"\4\0027\"\15\"\16$\0\0007#\11\0\16%\27\0\16&\28\0>#\4\0027#\15#\31\"#\" \"\"\30\30 \"!\16\"\17\0007!\11\17\16#\21\0\16$\25\0>!\4\2+\"\9\0\31#\26\ \31$\31 #$#\30##\31>\"\2\2:\"\15!K\22$\127K\18\31\127H\17\2\0\6À\3À\5À\4À\8À\9À\1À\2À\0À\7À\6b\6g\6r\8rgb\7at\9flat\ width\11height\9sin0\9cos0\7bi\7nn\21nearest neighbor\13bilinear\ lower\11stringÐ\5›¶¯‹\20÷Ãõ\3è\2\4\2\1\3\0\12\0\15\0\0234\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0014\2\2\0007\2\4\0024\3\2\0007\3\5\0034\4\2\0007\4\6\0044\5\2\0007\5\7\0054\6\2\0007\6\8\0061\7\9\0001\8\ \0001\9\11\0001\ \12\0003\11\13\0:\ \14\0110\0\0€H\11\2\0\11rotate\1\0\0\0\0\0\0\ floor\7pi\8sin\8cos\8max\8min\9math\ image\12require\0" ) package.preload["il.scale"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\2À\1€€€ÿ\3¥\9\0\4 \4\14\1’\2\15\0\3\0T\4\6€4\4\0\0007\4\1\4\16\5\3\0>\4\2\2\12\3\4\0T\5\1€%\3\2\0\6\3\3\0T\4\7€\6\3\4\0T\4\5€\6\3\2\0T\4\3€\6\3\5\0T\4\1€H\0\2\0007\4\6\0007\5\7\0!\6\1\4!\7\2\5+\8\0\0007\8\8\8\16\9\2\0\16\ \1\0>\8\3\2\6\3\3\0T\9\2€\7\3\4\0T\9'€'\9\0\0\21\ \0\1'\11\1\0I\9\"€+\13\1\0 \14\6\12>\13\2\2+\14\2\0\16\15\13\0\21\16\0\4>\14\3\2\16\13\14\0'\14\0\0\21\15\0\2'\16\1\0I\14\21€+\18\1\0 \19\7\17>\18\2\2+\19\2\0\16\20\18\0\21\21\0\5>\19\3\2\16\18\19\0\16\20\8\0007\19\9\8\16\21\12\0\16\22\17\0>\19\4\2\16\21\0\0007\20\9\0\16\22\13\0\16\23\18\0>\20\4\0027\20\ \20:\20\ \19K\14ë\127K\9Þ\127T\9ˀ\6\3\2\0T\9\2€\7\3\5\0T\9ǀ'\9\0\0\21\ \0\1'\11\1\0I\9À \13\6\12+\14\2\0\16\15\13\0\21\16\0\4>\14\3\2\16\13\14\0+\14\3\0\16\15\13\0>\14\2\2+\15\2\0\20\16\0\14\21\17\0\4>\15\3\2'\16\0\0\21\17\0\2'\18\1\0I\16±€ \20\7\19+\21\2\0\16\22\20\0\21\23\0\5>\21\3\2\16\20\21\0+\21\3\0\16\22\20\0>\21\2\2+\22\2\0\20\23\0\21\21\24\0\5>\22\3\2\31\23\21\20\16\25\0\0007\24\9\0\16\26\14\0\16\27\21\0>\24\4\0027\24\11\24\16\26\0\0007\25\9\0\16\27\14\0\16\28\22\0>\25\4\0027\25\11\25\16\27\0\0007\26\9\0\16\28\14\0\16\29\21\0>\26\4\0027\26\11\26\31\25\26\25 \25\25\23\30\24\25\24\16\26\0\0007\25\9\0\16\27\15\0\16\28\21\0>\25\4\0027\25\11\25\16\27\0\0007\26\9\0\16\28\15\0\16\29\22\0>\26\4\0027\26\11\26\16\28\0\0007\27\9\0\16\29\15\0\16\30\21\0>\27\4\0027\27\11\27\31\26\27\26 \26\26\23\30\25\26\25\16\27\8\0007\26\9\8\16\28\12\0\16\29\19\0>\26\4\2+\27\1\0\31\28\14\13\31\29\24\25 \28\29\28\30\28\28\24>\27\2\2:\27\11\26\16\27\0\0007\26\9\0\16\28\14\0\16\29\21\0>\26\4\0027\26\12\26\16\28\0\0007\27\9\0\16\29\14\0\16\30\22\0>\27\4\0027\27\12\27\16\29\0\0007\28\9\0\16\30\14\0\16\31\21\0>\28\4\0027\28\12\28\31\27\28\27 \27\27\23\30\24\27\26\16\27\0\0007\26\9\0\16\28\15\0\16\29\21\0>\26\4\0027\26\12\26\16\28\0\0007\27\9\0\16\29\15\0\16\30\22\0>\27\4\0027\27\12\27\16\29\0\0007\28\9\0\16\30\15\0\16\31\21\0>\28\4\0027\28\12\28\31\27\28\27 \27\27\23\30\25\27\26\16\27\8\0007\26\9\8\16\28\12\0\16\29\19\0>\26\4\2+\27\1\0\31\28\14\13\31\29\24\25 \28\29\28\30\28\28\24>\27\2\2:\27\12\26\16\27\0\0007\26\9\0\16\28\14\0\16\29\21\0>\26\4\0027\26\13\26\16\28\0\0007\27\9\0\16\29\14\0\16\30\22\0>\27\4\0027\27\13\27\16\29\0\0007\28\9\0\16\30\14\0\16\31\21\0>\28\4\0027\28\13\28\31\27\28\27 \27\27\23\30\24\27\26\16\27\0\0007\26\9\0\16\28\15\0\16\29\21\0>\26\4\0027\26\13\26\16\28\0\0007\27\9\0\16\29\15\0\16\30\22\0>\27\4\0027\27\13\27\16\29\0\0007\28\9\0\16\30\15\0\16\31\21\0>\28\4\0027\28\13\28\31\27\28\27 \27\27\23\30\25\27\26\16\27\8\0007\26\9\8\16\28\12\0\16\29\19\0>\26\4\2+\27\1\0\31\28\14\13\31\29\24\25 \28\29\28\30\28\28\24>\27\2\2:\27\13\26K\16O\127K\9=\127H\8\2\0\0À\3À\1À\2À\6b\6g\6r\8rgb\7at\9flat\ width\11height\7bi\7nn\21nearest neighbor\13bilinear\ lower\11string\2o\3\0\6\0\ \0\0144\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0014\2\2\0007\2\4\0021\3\5\0001\4\6\0003\5\7\0:\4\8\5:\4\9\0050\0\0€H\5\2\0\12rescale\ scale\1\0\0\0\0\ floor\8min\9math\ image\12require\0" ) package.preload["il.segment"] = load( "\27LJ\1\2’\2\0\3\18\0\0\2B\19\3\0\0008\4\0\0\19\4\4\0002\5\0\0'\6\1\0\16\7\1\0'\8\1\0I\6\3€'\ \0\0009\ \9\5K\6ý\127'\6\0\0\16\7\3\0'\8\1\0I\6\11€'\ \0\0\16\11\4\0'\12\1\0I\ \6€6\14\9\0006\14\13\0146\15\14\5\20\15\0\0159\15\14\5K\ ú\127K\6õ\1272\6\0\0'\7\1\0\16\8\1\0'\9\1\0I\7\3€6\11\ \0059\11\ \6K\7ý\127'\7\1\0'\8\1\0\16\9\1\0'\ \1\0I\8\ €6\12\11\5\1\12\2\0T\12\3€'\12\0\0009\12\11\6T\12\3€9\7\11\6\24\12\1\7\20\7\0\12K\8ö\127'\8\0\0\21\9\0\3'\ \1\0I\8\11€'\12\0\0\21\13\0\4'\14\1\0I\12\6€6\16\11\0006\17\11\0006\17\15\0176\17\17\0069\17\15\16K\12ú\127K\8õ\127)\8\2\0H\8\2\0\2þ\3@\0\2\5\4\0\1\12+\2\0\0+\3\1\0\16\4\0\0>\2\3\1+\2\0\0+\3\2\0\16\4\1\0>\2\3\1+\2\3\0\20\2\0\2,\3\2\0G\0\1\0\0\0\9À\ À\11€\2Ò\4\0\2\13\8\4\2Š\1'\2\0\0\0\0\2\0T\2\9€+\2\0\0\2\2\0\0T\2\6€'\2\0\0\0\1\2\0T\2\3€+\2\1\0\3\2\1\0T\2\2€)\2\1\0H\2\2\0+\2\2\0006\2\0\0026\2\1\2\8\2\0\0T\2\2€)\2\1\0H\2\2\0004\2\0\0007\2\1\2+\3\3\0\16\4\3\0007\3\2\3\16\5\0\0\16\6\1\0>\3\4\0027\3\3\0038\3\0\3+\4\4\0\31\3\4\3>\2\2\2+\3\5\0\1\3\2\0T\2\2€)\2\1\0H\2\2\0+\2\2\0006\2\0\2+\3\6\0009\3\1\2\21\2\1\1\21\3\1\1'\4\0\0'\5ÿÿI\3\28€+\7\2\0006\7\0\0076\7\6\7\9\7\0\0T\7\23€4\7\0\0007\7\1\7+\8\3\0\16\9\8\0007\8\2\8\16\ \0\0\16\11\6\0>\8\4\0027\8\3\0088\8\0\8+\9\4\0\31\8\9\8>\7\2\2+\8\5\0\1\8\7\0T\7\1€T\3\6€+\7\2\0006\7\0\7+\8\6\0009\8\6\7\16\2\6\0K\3ä\127\20\2\1\2\20\3\1\1\20\4\1\1+\5\1\0\21\5\1\5'\6\1\0I\4\28€+\8\2\0006\8\0\0086\8\7\8\9\8\0\0T\8\23€4\8\0\0007\8\1\8+\9\3\0\16\ \9\0007\9\2\9\16\11\0\0\16\12\7\0>\9\4\0027\9\3\0098\9\0\9+\ \4\0\31\9\ \9>\8\2\2+\9\5\0\1\9\8\0T\8\1€T\4\6€+\8\2\0006\8\0\8+\9\6\0009\9\7\8\16\3\7\0K\4ä\127\21\3\1\3'\4\0\0\1\4\0\0T\4\9€\16\4\2\0\16\5\3\0'\6\1\0I\4\5€+\8\7\0\21\9\1\0\16\ \7\0>\8\3\1K\4û\127+\4\0\0\21\4\1\4\1\0\4\0T\4\9€\16\4\2\0\16\5\3\0'\6\1\0I\4\5€+\8\7\0\20\9\1\0\16\ \7\0>\8\3\1K\4û\127G\0\1\0\7À\8À\1À\0À\4À\5À\6À\12À\8rgb\7at\8abs\9math\0\2‹\1\1\7\18\2\4\1\0287\7\0\0007\8\1\0002\9\0\0002\ \0\0'\11\0\0001\12\2\0001\13\3\0\16\14\13\0\16\15\2\0\16\16\3\0>\14\3\1'\14\0\0\1\14\11\0T\14\11€Q\14\ €\21\11\0\11\16\14\13\0+\15\1\0\16\16\9\0>\15\2\2+\16\1\0\16\17\ \0>\16\2\0=\14\1\1T\14ò\127)\14\2\0000\0\0€H\14\2\0\2À\3À\0\0\ width\11height\2Í\3\0\3\24\3\5\3h7\3\0\0007\4\1\0+\5\0\0007\5\2\5\16\6\0\0>\5\2\2\16\0\5\0002\5\0\0'\6\0\0\21\7\0\3'\8\1\0I\6\11€2\ \0\0009\ \9\5'\ \0\0\21\11\0\4'\12\1\0I\ \4€6\14\9\5'\15\0\0009\15\13\14K\ ü\127K\6õ\127'\6\0\0'\7\0\0\21\8\0\3'\9\1\0I\7+€'\11\0\0\21\12\0\4'\13\1\0I\11&€6\15\ \0056\15\14\15\9\15\1\0T\15!€\16\16\0\0007\15\3\0\16\17\ \0\16\18\14\0>\15\4\0027\15\4\0158\15\0\15\31\16\1\15'\17\0\0\1\16\17\0T\16\1€\16\15\1\0\30\16\1\15'\17ÿ\0\1\17\16\0T\16\1€\26\15\2\1\20\6\0\6\9\2\1\0T\16\4€'\16ÿ\0\1\16\6\0T\16\1€'\6\1\0+\16\1\0\16\17\0\0\16\18\5\0\16\19\ \0\16\20\14\0\16\21\15\0\16\22\1\0\16\23\6\0>\16\8\1K\11Ú\127K\7Õ\127'\7\0\0\1\7\2\0T\7\5€+\7\2\0\16\8\5\0\16\9\6\0\16\ \2\0>\7\4\1'\7\0\0\21\8\0\3'\9\1\0I\7\20€'\11\0\0\21\12\0\4'\13\1\0I\11\15€6\15\ \0056\15\14\15'\16\0\0'\17\2\0'\18\1\0I\16\8€\16\21\0\0007\20\3\0\16\22\ \0\16\23\14\0>\20\4\0027\20\4\0209\15\19\20K\16ø\127K\11ñ\127K\7ì\127H\0\2\0\0À\5À\4À\8rgb\7at\12RGB2YIQ\ width\11height\2\0þ\3\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0'\5\0\0@\2\4\0\6À\29\0\3\7\1\0\0\5+\3\0\0\16\4\0\0\16\5\1\0\16\6\2\0@\3\4\0\6ÀÐ\6\0\1\18\2\9\4Å\1+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0'\3\1\0\21\4\0\1'\5\1\0I\3B€'\7\1\0\21\8\1\2'\9\1\0I\7=€\16\12\0\0007\11\3\0\16\13\6\0\16\14\ \0>\11\4\0027\11\4\11+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\21\16\0\6\21\17\0\ >\14\4\0027\14\4\14\20\14\2\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\21\16\0\6\16\17\ \0>\14\4\0027\14\4\14\20\14\3\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\21\16\0\6\20\17\0\ >\14\4\0027\14\4\14\20\14\2\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\16\16\6\0\21\17\0\ >\14\4\0027\14\4\14\20\14\3\14>\12\3\2\16\11\12\0\16\13\0\0007\12\3\0\16\14\6\0\16\15\ \0>\12\4\2+\13\1\0\16\14\11\0'\15ÿ\0>\13\3\2:\13\4\12K\7Ã\127K\3¾\127\21\3\1\1'\4\0\0'\5ÿÿI\3B€\21\7\1\2'\8\1\0'\9ÿÿI\7=€\16\12\0\0007\11\3\0\16\13\6\0\16\14\ \0>\11\4\0027\11\4\11+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\16\16\6\0\20\17\0\ >\14\4\0027\14\4\14\20\14\3\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\20\16\0\6\21\17\0\ >\14\4\0027\14\4\14\20\14\2\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\20\16\0\6\16\17\ \0>\14\4\0027\14\4\14\20\14\3\14>\12\3\2\16\11\12\0+\12\1\0\16\13\11\0\16\15\0\0007\14\3\0\20\16\0\6\20\17\0\ >\14\4\0027\14\4\14\20\14\2\14>\12\3\2\16\11\12\0\16\13\0\0007\12\3\0\16\14\6\0\16\15\ \0>\12\4\2+\13\1\0\16\14\11\0'\15ÿ\0>\13\3\2:\13\4\12K\7Ã\127K\3¾\127'\3\0\0\21\4\0\1'\5\1\0I\3\15€\16\8\0\0007\7\3\0\16\9\6\0'\ \0\0>\7\4\2'\8\0\0:\8\4\7\16\8\0\0007\7\3\0\16\9\6\0\21\ \0\2>\7\4\2'\8\0\0:\8\4\7K\3ñ\127\16\4\0\0007\3\5\0>\3\2\4T\6\24€\16\9\0\0007\8\3\0\16\ \6\0\16\11\7\0>\8\4\2\16\ \0\0007\9\3\0\16\11\6\0\16\12\7\0>\9\4\0027\9\7\9:\9\6\8\16\9\0\0007\8\3\0\16\ \6\0\16\11\7\0>\8\4\2\16\ \0\0007\9\3\0\16\11\6\0\16\12\7\0>\9\4\0027\9\7\9:\9\8\8A\6\3\3N\6æ\127H\0\2\0\0À\1À\6b\6r\6g\11pixels\6y\7at\ width\11height\17GetIntensity\2\4\8\6°\1\3\0\11\0\17\0\0214\0\0\0%\1\1\0>\0\2\0024\1\2\0007\1\3\0014\2\4\0007\2\5\0024\3\4\0007\3\6\0031\4\7\0001\5\8\0001\6\9\0001\7\ \0001\8\11\0001\9\12\0003\ \13\0:\7\14\ :\8\15\ :\9\16\ 0\0\0€H\ \2\0\14chamfer34\15sizeFilter\13connComp\1\0\0\0\0\0\0\0\0\11remove\11insert\ table\8min\9math\13il.color\12require\0" ) package.preload["il.sharpen"] = load( "\27LJ\1\2ƒ\3\0\1\20\1\9\3Q7\1\0\0007\2\1\0+\3\0\0007\3\2\3\16\4\0\0>\3\2\2\16\0\3\0\16\4\0\0007\3\3\0>\3\2\0024\4\4\0007\4\5\4'\5\1\0\21\6\0\1'\7\1\0I\5=€'\9\1\0\21\ \0\2'\11\1\0I\0098€\16\13\4\0\16\15\0\0007\14\6\0\16\16\8\0\16\17\12\0>\14\4\0027\14\7\0148\14\0\14\27\14\1\14\16\16\0\0007\15\6\0\21\17\2\8\16\18\12\0>\15\4\0027\15\7\0158\15\0\15\16\17\0\0007\16\6\0\20\18\2\8\16\19\12\0>\16\4\0027\16\7\0168\16\0\16\30\15\16\15\16\17\0\0007\16\6\0\16\18\8\0\21\19\2\12>\16\4\0027\16\7\0168\16\0\16\30\15\16\15\16\17\0\0007\16\6\0\16\18\8\0\20\19\2\12>\16\4\0027\16\7\0168\16\0\16\30\15\16\15\31\14\15\14>\13\2\2\16\15\3\0007\14\6\3\16\16\8\0\16\17\12\0>\14\4\0027\14\7\14'\15ÿ\0\1\15\13\0T\15\2€'\15ÿ\0T\16\1€\16\15\13\0;\15\0\14K\9È\127K\5Ã\127+\5\0\0007\5\8\5\16\6\3\0@\5\2\0\0À\12YIQ2RGB\8rgb\7at\8abs\9math\ clone\12RGB2YIQ\ width\11height\4\ \2Ä\3\0\2\29\1\11\2_7\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\3\0>\4\2\2\15\0\1\0T\5\6€4\5\4\0007\5\5\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\4\0007\5\6\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0004\5\4\0007\5\6\0054\6\4\0007\6\7\6\16\7\1\0\31\8\1\2\21\8\1\8'\9\1\0I\0079€\16\11\1\0\31\12\1\3\21\12\1\12'\13\1\0I\0113€'\15ÿ\0'\16\0\0\18\17\1\0\16\18\1\0'\19\1\0I\17\23€\18\21\1\0\16\22\1\0'\23\1\0I\21\18€\16\26\0\0007\25\8\0\30\27\20\ \30\28\24\14>\25\4\0027\25\9\0258\25\0\25\16\26\6\0\16\27\15\0\16\28\25\0>\26\3\2\16\15\26\0\16\26\5\0\16\27\16\0\16\28\25\0>\26\3\2\16\16\26\0K\21î\127K\17é\127\16\18\0\0007\17\8\0\16\19\ \0\16\20\14\0>\17\4\0027\17\9\0178\17\0\17\31\18\15\17\31\19\17\16\1\18\19\0T\18\2€\12\17\15\0T\18\1€\16\17\16\0\16\19\4\0007\18\8\4\16\20\ \0\16\21\14\0>\18\4\0027\18\9\18;\17\0\18K\11Í\127K\7Ç\127+\7\0\0007\7\ \7\16\8\4\0@\7\2\0\0À\12YIQ2RGB\8rgb\7at\8min\8max\ floor\9math\ clone\12RGB2YIQ\ width\11height\4\2Z\3\0\4\0\7\0\ 4\0\0\0%\1\1\0>\0\2\0021\1\2\0001\2\3\0003\3\4\0:\1\5\3:\2\6\0030\0\0€H\3\2\0\17sharpenMorph\12sharpen\1\0\0\0\0\13il.color\12require\0" ) package.preload["il.smooth"] = load( "\27LJ\1\2Û\3\0\1\18\1\7\4i7\1\0\0007\2\1\0+\3\0\0007\3\2\3\16\4\0\0>\3\2\2\16\0\3\0\16\4\0\0007\3\3\0>\3\2\2'\4\1\0\21\5\0\1'\6\1\0I\4W€'\8\1\0\21\9\0\2'\ \1\0I\8R€\16\13\0\0007\12\4\0\16\14\7\0\16\15\11\0>\12\4\0027\12\5\0128\12\0\12\27\12\1\12\16\14\0\0007\13\4\0\21\15\2\7\16\16\11\0>\13\4\0027\13\5\0138\13\0\13\16\15\0\0007\14\4\0\20\16\2\7\16\17\11\0>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\16\15\0\0007\14\4\0\16\16\7\0\21\17\2\11>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\16\15\0\0007\14\4\0\16\16\7\0\20\17\2\11>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\27\13\0\13\30\12\13\12\16\14\0\0007\13\4\0\21\15\2\7\21\16\2\11>\13\4\0027\13\5\0138\13\0\13\16\15\0\0007\14\4\0\21\16\2\7\20\17\2\11>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\16\15\0\0007\14\4\0\20\16\2\7\21\17\2\11>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\16\15\0\0007\14\4\0\20\16\2\7\20\17\2\11>\14\4\0027\14\5\0148\14\0\14\30\13\14\13\30\12\13\12\16\14\3\0007\13\4\3\16\15\7\0\16\16\11\0>\13\4\0027\13\5\13\23\14\3\12;\14\0\13K\8®\127K\4©\127+\4\0\0007\4\6\4\16\5\3\0@\4\2\0\0À\12YIQ2RGB\8rgb\7at\ clone\12RGB2YIQ\ width\11height\4\8\2 À\4\0\3\26\1\ \2\1277\3\0\0007\4\1\0\15\0\1\0T\5\6€4\5\2\0007\5\3\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\2\0007\5\4\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0\14\0\2\0T\5\11€2\2\0\0'\5\1\0\30\6\1\1\20\6\1\6'\7\1\0I\5\5€\19\9\2\0\20\9\1\9'\ \1\0009\ \9\2K\5û\127'\5\0\0'\6\1\0\19\7\2\0'\8\1\0I\6\3€6\ \9\2\30\5\ \5K\6ý\127+\6\0\0007\6\5\6\16\7\0\0>\6\2\2\16\0\6\0\16\7\0\0007\6\6\0>\6\2\2\16\8\0\0007\7\6\0>\7\2\2'\8\0\0\21\9\1\3'\ \1\0I\8!€\16\12\1\0\31\13\1\4\21\13\1\13'\14\1\0I\12\27€'\16\0\0\20\17\1\1\18\18\1\0\16\19\1\0'\20\1\0I\18\12€\16\23\0\0007\22\7\0\16\24\11\0\30\25\21\15>\22\4\0027\22\8\0228\22\0\22\30\23\21\0176\23\23\2 \22\23\22\30\16\22\16K\18ô\127\16\19\6\0007\18\7\6\16\20\11\0\16\21\15\0>\18\4\0027\18\8\18!\19\5\16;\19\0\18K\12å\127K\8ß\127'\8\0\0\21\9\1\4'\ \1\0I\8!€\16\12\1\0\31\13\1\3\21\13\1\13'\14\1\0I\12\27€'\16\0\0\20\17\1\1\18\18\1\0\16\19\1\0'\20\1\0I\18\12€\16\23\6\0007\22\7\6\30\24\21\15\16\25\11\0>\22\4\0027\22\8\0228\22\0\22\30\23\21\0176\23\23\2 \22\23\22\30\16\22\16K\18ô\127\16\19\7\0007\18\7\7\16\20\15\0\16\21\11\0>\18\4\0027\18\8\18!\19\5\16;\19\0\18K\12å\127K\8ß\127+\8\0\0007\8\9\8\16\9\7\0@\8\2\0\0À\12YIQ2RGB\8rgb\7at\ clone\12RGB2YIQ\8max\ floor\9math\ width\11height\4\2Ê\1\0\2\9\1\3\2,\15\0\1\0T\2\6€4\2\0\0007\2\1\2\23\3\0\1>\2\2\2\12\1\2\0T\3\1€'\1\1\0004\2\0\0007\2\2\2\16\3\1\0'\4\1\0>\2\3\2\16\1\2\0002\2\0\0\20\3\1\1'\4\1\0\16\5\1\0'\6\1\0I\4\5€\19\8\2\0\20\8\1\0089\7\8\2\30\3\7\3K\4û\127\19\4\2\0\20\4\1\4\20\5\1\0019\5\4\2\16\4\1\0'\5\1\0'\6ÿÿI\4\5€\19\8\2\0\20\8\1\0089\7\8\2\30\3\7\3K\4û\127+\4\0\0\16\5\0\0\16\6\1\0\16\7\2\0@\4\4\0\2À\8max\ floor\9math\4\2Ö\1\0\2\ \1\3\2/\15\0\1\0T\2\6€4\2\0\0007\2\1\2\23\3\0\1>\2\2\2\12\1\2\0T\3\1€'\1\1\0004\2\0\0007\2\2\2\16\3\1\0'\4\1\0>\2\3\2\16\1\2\0002\2\0\0'\3\0\0'\4\1\0'\5\1\0\16\6\1\0'\7\1\0I\5\6€\19\9\2\0\20\9\1\0099\4\9\2\30\3\4\3\22\4\0\4K\5ú\127\19\5\2\0\20\5\1\0059\4\5\2\30\3\4\3\16\5\1\0'\6\1\0'\7ÿÿI\5\6€\23\4\0\4\19\9\2\0\20\9\1\0099\4\9\2\30\3\4\3K\5ú\127+\5\0\0\16\6\0\0\16\7\1\0\16\8\2\0@\5\4\0\2À\8max\ floor\9math\4\2«\1\0\1\11\0\4\4!'\1\0\0\3\0\1\0T\1\2€)\1\0\0H\1\2\0004\1\0\0007\1\1\1\27\2\0\0\20\2\1\2>\1\2\0024\2\0\0007\2\2\2\16\3\1\0'\4\1\0>\2\3\2\16\1\2\0\27\2\2\0 \2\0\0022\3\0\0\18\4\1\0\16\5\1\0'\6\1\0I\4\9€\30\8\1\7\20\8\3\0084\9\0\0007\9\3\9 \ \7\7!\ \2\ >\9\2\0029\9\8\3K\4÷\127H\3\2\0\8exp\8max\ floor\9math\6\1€€€ÿ\3üÿÿÿ\31\2G\0\2\7\2\0\0\15+\2\0\0\16\3\1\0>\2\2\2\15\0\2\0T\3\4€\19\3\2\0'\4\3\0\1\3\4\0T\3\1€H\0\2\0+\3\1\0\16\4\0\0\19\5\2\0\16\6\2\0@\3\4\0\5À\2Àä\2\0\2\27\1\ \2H7\2\0\0007\3\1\0+\4\0\0007\4\2\4\16\5\0\0>\4\2\2\16\0\4\0\16\5\0\0007\4\3\0>\4\2\2\15\0\1\0T\5\6€4\5\4\0007\5\5\5\23\6\0\1>\5\2\2\12\1\5\0T\6\1€'\1\1\0004\5\4\0007\5\6\5\16\6\1\0'\7\1\0>\5\3\2\16\1\5\0\30\5\1\1\20\5\1\5'\6\2\0#\5\6\5\16\6\1\0\31\7\1\2\21\7\1\7'\8\1\0I\6\"€\16\ \1\0\31\11\1\3\21\11\1\11'\12\1\0I\ \28€'\14\0\0\18\15\1\0\16\16\1\0'\17\1\0I\15\14€\18\19\1\0\16\20\1\0'\21\1\0I\19\9€\16\24\0\0007\23\7\0\30\25\18\9\30\26\22\13>\23\4\0027\23\8\0238\23\0\23\30\14\23\14K\19÷\127K\15ò\127\16\16\4\0007\15\7\4\16\17\9\0\16\18\13\0>\15\4\0027\15\8\15!\16\5\14;\16\0\15K\ ä\127K\6Þ\127+\6\0\0007\6\9\6\16\7\4\0@\6\2\0\0À\12YIQ2RGB\8rgb\7at\8max\ floor\9math\ clone\12RGB2YIQ\ width\11height\4\2‹\1\3\0\9\0\15\0\0184\0\0\0%\1\1\0>\0\2\0021\1\2\0001\2\3\0001\3\4\0001\4\5\0001\5\6\0001\6\7\0001\7\8\0003\8\9\0:\1\ \8:\2\11\8:\3\12\8:\4\13\8:\6\14\0080\0\0€H\8\2\0\11meanW3\11meanW2\11meanW1\9mean\11smooth\1\0\0\0\0\0\0\0\0\0\13il.color\12require\0" ) package.preload["il.stat"] = load( "\27LJ\1\2É\3\0\3 \1\12\2_7\3\0\0007\4\1\0+\5\0\0007\5\2\5\16\6\0\0>\5\2\2\16\0\5\0\16\6\0\0007\5\3\0>\5\2\2\15\0\1\0T\6\6€4\6\4\0007\6\5\6\23\7\0\1>\6\2\2\12\1\6\0T\7\1€'\1\1\0004\6\4\0007\6\6\6\16\7\1\0'\8\1\0>\6\3\2\16\1\6\0004\6\4\0007\6\7\0064\7\4\0007\7\8\7\30\8\1\1\20\8\1\8'\9\2\0#\8\9\8\21\9\1\8\16\ \1\0\31\11\1\3\21\11\1\11'\12\1\0I\ 4€\16\14\1\0\31\15\1\4\21\15\1\15'\16\1\0I\14.€'\18\0\0'\19\0\0\18\20\1\0\16\21\1\0'\22\1\0I\20\16€\18\24\1\0\16\25\1\0'\26\1\0I\24\11€\16\29\0\0007\28\9\0\30\30\23\13\30\31\27\17>\28\4\0027\28\ \0288\28\0\28\30\18\28\18 \29\28\28\30\19\29\19K\24õ\127K\20ð\127!\20\8\18 \20\18\20\31\20\20\19!\20\9\20\15\0\2\0T\21\5€\16\21\7\0\16\22\20\0>\21\2\2\12\20\21\0T\22\0€\16\21\6\0\16\22\20\0'\23ÿ\0>\21\3\2\16\20\21\0\16\22\5\0007\21\9\5\16\23\13\0\16\24\17\0>\21\4\0027\21\ \21;\20\0\21K\14Ò\127K\ Ì\127+\ \0\0007\ \11\ \16\11\5\0@\ \2\0\0À\12YIQ2RGB\8rgb\7at\9sqrt\8min\8max\ floor\9math\ clone\12RGB2YIQ\ width\11height\4\2\29\0\2\6\1\0\0\5+\2\0\0\16\3\0\0\16\4\1\0)\5\2\0@\2\4\0\2ÀŒ\5\0\3\29\3\13\2Œ\0017\3\0\0007\4\1\0+\5\0\0007\5\2\5\16\6\0\0>\5\2\2\16\0\5\0'\5\0\0'\6\0\0'\7\0\0\21\8\0\3'\9\1\0I\7\16€'\11\0\0\21\12\0\4'\13\1\0I\11\11€\16\16\0\0007\15\3\0\16\17\ \0\16\18\14\0>\15\4\0027\15\4\0158\15\0\15\30\5\15\5 \16\15\15\30\6\16\6K\11õ\127K\7ð\1274\7\5\0007\7\6\7 \8\5\5 \9\4\3!\8\9\8\31\8\8\6 \9\4\3\21\9\0\9!\8\9\8>\7\2\2\16\9\0\0007\8\7\0>\8\2\2+\9\0\0007\9\2\9+\ \1\0007\ \8\ \16\11\0\0\16\12\1\0>\ \3\0=\9\0\2+\ \0\0007\ \2\ +\11\2\0\16\12\0\0\16\13\1\0>\11\3\0=\ \0\0024\11\5\0007\11\9\0114\12\5\0007\12\ \0124\13\5\0007\13\11\13'\14\0\0\21\15\0\3'\16\1\0I\14E€'\18\0\0\21\19\0\4'\20\1\0I\18@€\16\23\ \0007\22\3\ \16\24\17\0\16\25\21\0>\22\4\0027\22\4\0228\22\0\22'\23\0\0\1\23\22\0T\0225€\16\22\13\0 \23\7\2\16\25\0\0007\24\3\0\16\26\17\0\16\27\21\0>\24\4\0027\24\4\0248\24\0\24\16\26\9\0007\25\3\9\16\27\17\0\16\28\21\0>\25\4\0027\25\4\0258\25\0\25\31\24\25\24 \23\24\23\16\25\ \0007\24\3\ \16\26\17\0\16\27\21\0>\24\4\0027\24\4\0248\24\0\24!\23\24\23\16\25\9\0007\24\3\9\16\26\17\0\16\27\21\0>\24\4\0027\24\4\0248\24\0\24\30\23\24\23\20\23\1\23>\22\2\2\16\23\11\0\16\24\22\0'\25\0\0>\23\3\2\16\22\23\0\16\23\12\0\16\24\22\0'\25ÿ\0>\23\3\2\16\22\23\0\16\24\8\0007\23\3\8\16\25\17\0\16\26\21\0>\23\4\0027\23\4\23;\22\0\23K\18À\127K\14»\127+\14\0\0007\14\12\14\16\15\8\0@\14\2\0\0À\1À\3À\12YIQ2RGB\ floor\8min\8max\9mean\ clone\9sqrt\9math\8rgb\7at\12RGB2YIQ\ width\11height\2\1€€€ÿ\3}\3\0\6\0\ \0\0154\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0021\2\3\0001\3\4\0001\4\5\0003\5\6\0:\2\7\5:\3\8\5:\4\9\0050\0\0€H\5\2\0\13statDiff\11stdDev\13variance\1\0\0\0\0\0\14il.smooth\13il.color\12require\0" ) package.preload["il.threshold"] = load( "\27LJ\1\2\27\0\1\3\1\0\1\3+\1\0\0\20\2\0\0@\1\2\0\4À\1€€€ÿ\3o\0\3\7\1\0\3\18\27\3\0\0\27\4\1\1\30\3\4\3\27\4\2\2\30\3\4\3+\4\0\0\1\3\4\0T\4\5€'\4\0\0'\5\0\0'\6\0\0F\4\4\0T\4\4€'\4ÿ\0'\5ÿ\0'\6ÿ\0F\4\4\0G\0\1\0\1Àç̙³\6³æÌþ\3Ãë£á\21Ç‹ÿ\3Óðú¨\24õÑðý\3&\1\2\5\0\2\0\5\16\3\0\0007\2\0\0001\4\1\0000\0\0€@\2\3\0\0\14mapPixels\3\0\1\12\3\7\3O+\1\0\0007\1\0\1\16\2\0\0>\1\2\2'\2\0\0'\3\0\0'\4\1\0'\5ÿ\0'\6\1\0I\4\6€6\8\7\1 \8\8\7\30\2\8\0026\8\7\1\30\3\8\3K\4ú\127+\4\1\0!\5\3\2\20\5\0\5>\4\2\2'\5ÿÿ\4\5\4\0T\6-€Q\6,€'\6\0\0'\3\0\0\16\2\6\0'\6\0\0\21\7\1\4'\8\1\0I\6\6€6\ \9\1 \ \ \9\30\2\ \0026\ \9\1\30\3\ \3K\6ú\127+\6\1\0!\7\3\2\20\7\0\7>\6\2\2'\7\0\0'\3\0\0\16\2\7\0\16\7\4\0'\8ÿ\0'\9\1\0I\7\6€6\11\ \1 \11\11\ \30\2\11\0026\11\ \1\30\3\11\3K\7ú\1274\7\1\0007\7\2\7!\8\3\2\20\8\0\8>\7\2\2\16\5\4\0004\8\1\0007\8\2\8\30\9\7\6\23\9\2\9\20\9\0\9>\8\2\2\16\4\8\0T\6Ñ\1274\6\3\0007\6\4\6%\7\5\0\16\8\4\0%\9\6\0$\7\9\7>\6\2\1+\6\2\0\16\7\0\0\16\8\4\0@\6\3\0\0À\4À\6À\6\ \"iterative binary threshold = \ write\7io\ floor\9math\14histogram\1€€€ÿ\3\2\4¡\5\0\1\18\5\12\4‰\1+\1\0\0007\1\0\1\16\2\0\0>\1\2\2\16\0\1\0007\1\1\0007\2\2\0004\3\3\0007\3\4\3\16\4\2\0\16\5\1\0>\3\3\0022\4\0\0'\5\0\0'\6ÿ\0'\7\1\0I\5\3€'\9\0\0009\9\8\4K\5ý\127\16\6\0\0007\5\5\0'\7\1\0>\5\3\4T\0083€\16\11\0\0007\ \6\0\16\12\8\0\16\13\9\0>\ \4\0027\ \7\ \27\ \0\ \16\12\0\0007\11\6\0\21\13\1\8\16\14\9\0>\11\4\0027\11\7\11\31\ \11\ \16\12\0\0007\11\6\0\20\13\1\8\16\14\9\0>\11\4\0027\11\7\11\31\ \11\ \16\12\0\0007\11\6\0\16\13\8\0\21\14\1\9>\11\4\0027\11\7\11\31\ \11\ \16\12\0\0007\11\6\0\16\13\8\0\20\14\1\9>\11\4\0027\11\7\11\31\ \11\ +\11\1\0+\12\2\0\16\13\ \0>\12\2\2'\13ÿ\0>\11\3\2\16\ \11\0006\11\ \4\20\11\1\0119\11\ \4\16\12\3\0007\11\6\3\16\13\8\0\16\14\9\0>\11\4\2:\ \7\11A\8\3\3N\8Ë\127'\5\0\0'\6\0\0+\7\3\0\21\8\2\1\27\8\3\8\21\9\2\2 \8\9\8>\7\2\2'\8\0\0'\9ÿ\0'\ \1\0I\8\7€\16\5\11\0006\12\11\4\30\6\12\6\3\7\6\0T\12\1€T\8\1€K\8ù\127'\8\0\0'\7\0\0\16\ \0\0007\9\5\0'\11\1\0>\9\3\4T\12\16€\16\15\3\0007\14\6\3\16\16\12\0\16\17\13\0>\14\4\0027\14\7\14\3\5\14\0T\14\8€\16\15\0\0007\14\6\0\16\16\12\0\16\17\13\0>\14\4\0027\14\7\14\30\8\14\8\20\7\1\7A\12\3\3N\12î\127+\9\3\0!\ \7\8>\9\2\2\16\5\9\0004\9\8\0007\9\9\9%\ \ \0\16\11\5\0%\12\11\0$\ \12\ >\9\2\1+\9\4\0\16\ \0\0\16\11\5\0@\9\3\0\1À\3À\2À\5À\6À\6\ &85% Laplacian binary threshold = \ write\7io\6y\7at\11pixels\9flat\ image\ width\11height\17getIntensity\8\2\4ç̙³\6³æ¬ÿ\3É\1\3\0\ \0\15\0\0224\0\0\0%\1\1\0>\0\2\0024\1\0\0%\2\2\0>\1\2\0024\2\3\0007\2\4\0024\3\3\0007\3\5\0034\4\3\0007\4\6\0041\5\7\0001\6\8\0001\7\9\0001\8\ \0003\9\11\0:\6\12\9:\7\13\9:\8\14\0090\0\0€H\9\2\0\23laplacianThreshold\29iterativeBinaryThreshold\14threshold\1\0\0\0\0\0\0\ floor\8min\8abs\9math\13il.color\13il.histo\12require\0" ) package.preload["il.utils"] = load( "\27LJ\1\2n\2\1\7\1\5\0\0174\1\0\0007\1\1\1>\1\1\2+\2\0\0\16\3\0\0C\4\1\0=\2\1\0024\3\0\0007\3\1\3>\3\1\0024\4\2\0007\4\3\4%\5\4\0\31\6\1\3$\5\6\5>\4\2\1H\2\2\0\0À\19elapsed time: \ write\7io\ clock\7os\20\1\1\2\0\1\0\0031\1\0\0000\0\0€H\1\2\0\0004\0\1\5\2\2\0\7+\1\0\0\16\2\0\0004\3\0\0007\3\1\3+\4\1\0>\3\2\0?\1\1\0\0À\1À\11unpack\ table&\3\1\3\0\1\1\0062\1\3\0C\2\1\0<\2\0\0001\2\0\0000\0\0€H\2\2\0\0\3€€À™\0044\3\0\3\0\5\0\0071\0\0\0001\1\1\0003\2\2\0:\0\3\2:\1\4\0020\0\0€H\2\2\0\ curry\ timed\1\0\0\0\0\0" ) package.preload["il"] = load( "\27LJ\1\2í\2\2\0\15\0\ \0 3\0\0\0002\1\0\0004\2\1\0\16\3\0\0>\2\2\4T\5\23€4\7\2\0004\8\3\0%\9\4\0\16\ \6\0$\9\ \9>\7\3\3\15\0\7\0T\9\8€4\9\5\0\16\ \8\0>\9\2\4D\12\1€9\13\12\1B\12\3\3N\12ý\127T\9\7€4\9\6\0007\9\7\9%\ \8\0\16\11\6\0%\12\9\0$\ \12\ >\9\2\1A\5\3\3N\5ç\127H\1\2\0\6\ \30failed to load il module \ write\7io\ pairs\8il.\12require\ pcall\11ipairs\1\24\0\0\8abt\8ahe\ arith\ color\9edge\15fftdisplay\11fftlib\13freqfilt\ histo\16historender\11median\11minmax\9misc\ morph\ point\11rotate\ scale\12segment\12sharpen\11smooth\9stat\14threshold\ utils\0" )
mit
Mistranger/OpenRA
mods/d2k/maps/atreides-02a/atreides02a.lua
5
3976
--[[ Copyright 2007-2017 The OpenRA Developers (see AUTHORS) This file is part of OpenRA, which is free software. It is made available to you under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For more information, see COPYING. ]] HarkonnenBase = { HConyard, HPower1, HPower2, HBarracks } HarkonnenReinforcements = { } HarkonnenReinforcements["easy"] = { { "light_inf", "trike" }, { "light_inf", "trike" }, { "light_inf", "light_inf", "light_inf", "trike", "trike" } } HarkonnenReinforcements["normal"] = { { "light_inf", "trike" }, { "light_inf", "trike" }, { "light_inf", "light_inf", "light_inf", "trike", "trike" }, { "light_inf", "light_inf" }, { "light_inf", "light_inf", "light_inf" }, { "light_inf", "trike" }, } HarkonnenReinforcements["hard"] = { { "trike", "trike" }, { "light_inf", "trike" }, { "light_inf", "trike" }, { "light_inf", "light_inf", "light_inf", "trike", "trike" }, { "light_inf", "light_inf" }, { "trike", "trike" }, { "light_inf", "light_inf", "light_inf" }, { "light_inf", "trike" }, { "trike", "trike" } } HarkonnenAttackPaths = { { HarkonnenEntry1.Location, HarkonnenRally1.Location }, { HarkonnenEntry1.Location, HarkonnenRally3.Location }, { HarkonnenEntry2.Location, HarkonnenRally2.Location }, { HarkonnenEntry2.Location, HarkonnenRally4.Location } } HarkonnenAttackDelay = { } HarkonnenAttackDelay["easy"] = DateTime.Minutes(5) HarkonnenAttackDelay["normal"] = DateTime.Minutes(2) + DateTime.Seconds(40) HarkonnenAttackDelay["hard"] = DateTime.Minutes(1) + DateTime.Seconds(20) HarkonnenAttackWaves = { } HarkonnenAttackWaves["easy"] = 3 HarkonnenAttackWaves["normal"] = 6 HarkonnenAttackWaves["hard"] = 9 wave = 0 SendHarkonnen = function() Trigger.AfterDelay(HarkonnenAttackDelay[Map.LobbyOption("difficulty")], function() wave = wave + 1 if wave > HarkonnenAttackWaves[Map.LobbyOption("difficulty")] then return end local path = Utils.Random(HarkonnenAttackPaths) local units = Reinforcements.ReinforceWithTransport(harkonnen, "carryall.reinforce", HarkonnenReinforcements[Map.LobbyOption("difficulty")][wave], path, { path[1] })[2] Utils.Do(units, IdleHunt) SendHarkonnen() end) end IdleHunt = function(unit) Trigger.OnIdle(unit, unit.Hunt) end Tick = function() if player.HasNoRequiredUnits() then harkonnen.MarkCompletedObjective(KillAtreides) end if harkonnen.HasNoRequiredUnits() and not player.IsObjectiveCompleted(KillHarkonnen) then Media.DisplayMessage("The Harkonnen have been annihilated!", "Mentat") player.MarkCompletedObjective(KillHarkonnen) end end WorldLoaded = function() harkonnen = Player.GetPlayer("Harkonnen") player = Player.GetPlayer("Atreides") InitObjectives() Camera.Position = AConyard.CenterPosition Trigger.OnAllKilled(HarkonnenBase, function() Utils.Do(harkonnen.GetGroundAttackers(), IdleHunt) end) SendHarkonnen() Trigger.AfterDelay(0, ActivateAI) end InitObjectives = function() Trigger.OnObjectiveAdded(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) KillAtreides = harkonnen.AddPrimaryObjective("Kill all Atreides units.") KillHarkonnen = player.AddPrimaryObjective("Destroy all Harkonnen forces.") Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) Trigger.OnObjectiveFailed(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") end) Trigger.OnPlayerLost(player, function() Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(player, "Lose") end) end) Trigger.OnPlayerWon(player, function() Trigger.AfterDelay(DateTime.Seconds(1), function() Media.PlaySpeechNotification(player, "Win") end) end) end
gpl-3.0
nobie/sesame_fw
feeds/luci/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/disk.lua
86
1449
--[[ Luci statistics - df plugin diagram definition (c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id: df.lua 2274 2008-06-03 23:15:16Z jow $ ]]-- module("luci.statistics.rrdtool.definitions.disk", package.seeall) function rrdargs( graph, plugin, plugin_instance, dtype ) return { { title = "%H: Disk I/O operations on %pi", vlabel = "Operations/s", number_format = "%5.1lf%sOp/s", data = { types = { "disk_ops" }, sources = { disk_ops = { "read", "write" }, }, options = { disk_ops__read = { title = "Reads", color = "00ff00", flip = false }, disk_ops__write = { title = "Writes", color = "ff0000", flip = true } } } }, { title = "%H: Disk I/O bandwidth on %pi", vlabel = "Bytes/s", number_format = "%5.1lf%sB/s", detail = true, data = { types = { "disk_octets" }, sources = { disk_octets = { "read", "write" } }, options = { disk_octets__read = { title = "Read", color = "00ff00", flip = false }, disk_octets__write = { title = "Write", color = "ff0000", flip = true } } } } } end
gpl-2.0
arya5123/tell
plugins/danbooro.lua
616
1750
do local URL = "http://danbooru.donmai.us" local URL_NEW = "/posts.json" local URL_POP = "/explore/posts/popular.json" local scale_day = "?scale=day" local scale_week = "?scale=week" local scale_month = "?scale=month" local function get_post(url) local b, c, h = http.request(url) if c ~= 200 then return nil end local posts = json:decode(b) return posts[math.random(#posts)] end local function run(msg, matches) local url = URL if matches[1] == "!danbooru" then url = url .. URL_NEW else url = url .. URL_POP if matches[1] == "d" then url = url .. scale_day elseif matches[1] == "w" then url = url .. scale_week elseif matches[1] == "m" then url = url .. scale_month end end local post = get_post(url) if post then vardump(post) local img = URL .. post.large_file_url send_photo_from_url(get_receiver(msg), img) local txt = '' if post.tag_string_artist ~= '' then txt = 'Artist: ' .. post.tag_string_artist .. '\n' end if post.tag_string_character ~= '' then txt = txt .. 'Character: ' .. post.tag_string_character .. '\n' end if post.file_size ~= '' then txt = txt .. '[' .. math.ceil(post.file_size/1000) .. 'kb] ' .. URL .. post.file_url end return txt end end return { description = "Gets a random fresh or popular image from Danbooru", usage = { "!danbooru - gets a random fresh image from Danbooru 🔞", "!danboorud - random daily popular image 🔞", "!danbooruw - random weekly popular image 🔞", "!danboorum - random monthly popular image 🔞" }, patterns = { "^!danbooru$", "^!danbooru ?(d)$", "^!danbooru ?(w)$", "^!danbooru ?(m)$" }, run = run } end
gpl-2.0
kapouer/upcache
upcache/lock.lua
2
3930
local jwt = require 'resty.jwt' local validators = require "resty.jwt-validators" local common = require 'upcache.common' local console = common.console local module = {} local headerLock = common.prefixHeader .. "-Lock" local headerKey = common.prefixHeader .. "-Lock-Key" local headerVar = common.prefixHeader .. "-Lock-Var" local upcacheLocks = 'upcacheLocks' -- star is voluntarily removed from that pattern local quotepattern = '(['..("%^$().[]+-?"):gsub("(.)", "%%%1")..'])' local function quoteReg(str) return str:gsub(quotepattern, "%%%1") end local function logKey(from, what, key, data) if string.find(key, quoteReg(what) .. "$") == nil then return end console.info(from, " ", key, console.encode(data)) end local function authorize(locks, token) -- array of used grants local grants = {} if locks == nil then return grants end if token == nil then return grants end local grant, found for i, lock in ipairs(locks) do found = false if lock:find("%*") and token.grants ~= nil then local regstr = "^" .. quoteReg(lock):gsub('*', '.*') .. "$" for i, grant in ipairs(token.grants) do if grant:find(regstr) ~= nil then table.insert(grants, grant) break end end elseif lock:find(":") then grant = string.gsub(lock, "%w*:(%w+)", function(key) local val = token[key] if val ~= nil then found = true return token[key] end end) if found == true then table.insert(grants, grant) end elseif token.grants ~= nil then for i, grant in ipairs(token.grants) do if grant == lock then table.insert(grants, grant) break end end end end if #grants > 0 then table.sort(grants) end return grants end local function build_key(key, locks, token) local grants = authorize(locks, token) local str = table.concat(grants, ',') if str:len() > 0 then key = str .. ' ' .. key end return key end local function get_locks(key) return common.get(common.variants, key, 'locks') end local function update_locks(key, data) common.set(common.variants, key, data, 'locks') end local function get_jwt(conf, vars) if conf.key == nil then return nil end local varname = conf.varname if varname == nil then varname = "cookie_bearer" end local bearer = vars[varname] if bearer == nil then return nil end local jwt_obj = jwt:load_jwt(bearer) local verified = jwt:verify_jwt_obj(conf.key, jwt_obj, { iss = validators.equals(vars.host) }) if jwt_obj == nil or verified == false then return nil end return jwt_obj.payload end local function request(vars) local conf = common.get(upcacheLocks, vars.host) if conf.key == nil then ngx.req.set_header(headerKey, "1") end return conf end module.request = request local function response(vars, ngx) local host = vars.host local headers = ngx.header local varname = headers[headerVar] local key = headers[headerKey] local conf = common.get(upcacheLocks, host) local update = false if varname ~= nil then console.info("response sets var on '", host, "': ", varname) conf.varname = varname headers[headerVar] = nil update = true end if key ~= nil then console.info("response sets key on '", host, "' with ", key:len(), " bytes") key = ngx.unescape_uri(key) conf.key = key headers[headerKey] = nil update = true end if update then common.set(upcacheLocks, host, conf) end return conf end module.response = response function module.jwt(vars, ngx) return console.encode(get_jwt(request(vars), vars)) end function module.get(key, vars, ngx) local conf = request(vars) return build_key(key, get_locks(key), get_jwt(conf, vars)) end function module.set(key, vars, ngx) local headers = ngx.header local conf = response(vars, ngx) local locks = common.parseHeader(headers[headerLock]) if locks == nil then return key end update_locks(key, locks) return build_key(key, locks, get_jwt(conf, vars)) end return module;
mit
gajop/Zero-K
LuaUI/Widgets/gui_replace_cloak_con_order.lua
12
2136
function widget:GetInfo() return { name = "Replace Cloak Con Orders", desc = "Prevents constructor accidental decloak in enemy territory by replacing Repair, Reclaim and Rez with Move. .\n\nNOTE:Use command menu or command hotkeys to override.", author = "GoogleFrog", date = "13 August 2011", license = "GNU GPL, v2 or later", layer = 0, enabled = false -- loaded by default? } end options_path = 'Game/Unit AI/Replace Cloak Con Orders' options = { reclaim = {name='Replace Reclaim', type='bool', value=true}, resurrect = {name='Replace Resurrect', type='bool', value=true}, repair = {name='Replace Repair', type='bool', value=true}, } function widget:CommandNotify(id, params, cmdOptions) if cmdOptions.right and #params < 4 and ((id == CMD.REPAIR and options.repair.value) or (id == CMD.RECLAIM and options.reclaim.value) or (id == CMD.RESURRECT and options.resurrect.value)) then local selUnits = Spring.GetSelectedUnits() local replace = false for i = 1, #selUnits do local unitID = selUnits[i] local ud = Spring.GetUnitDefID(unitID) -- assumption here is that everything that can repair or rez can also reclaim if ud and UnitDefs[ud] and UnitDefs[ud].canReclaim and Spring.GetUnitIsCloaked(unitID) and UnitDefs[ud].speed > 0 then replace = true break end end if replace then local x,y,z if #params == 1 then if id == CMD.REPAIR then if Spring.ValidUnitID(params[1]) and Spring.GetUnitPosition(params[1]) then x,_,z = Spring.GetUnitPosition(params[1]) y = Spring.GetGroundHeight(x,z) end else params[1] = params[1] - Game.maxUnits if Spring.ValidFeatureID(params[1]) and Spring.GetFeaturePosition(params[1]) then x,_,z = Spring.GetFeaturePosition(params[1]) y = Spring.GetGroundHeight(x,z) end end else x,y,z = params[1], params[2], params[3] end if x and y then for i = 1, #selUnits do local unitID = selUnits[i] Spring.GiveOrderToUnit(unitID,CMD.MOVE,{x,y,z},cmdOptions) end end end return replace end return false end
gpl-2.0
Flourish-Team/Flourish
Premake/source/binmodules/luasocket/test/testmesg.lua
45
2957
-- load the smtp support and its friends local smtp = require("socket.smtp") local mime = require("mime") local ltn12 = require("ltn12") function filter(s) if s then io.write(s) end return s end source = smtp.message { headers = { ['content-type'] = 'multipart/alternative' }, body = { [1] = { headers = { ['Content-type'] = 'text/html' }, body = "<html> <body> Hi, <b>there</b>...</body> </html>" }, [2] = { headers = { ['content-type'] = 'text/plain' }, body = "Hi, there..." } } } r, e = smtp.send{ rcpt = {"<diego@tecgraf.puc-rio.br>", "<diego@princeton.edu>" }, from = "<diego@princeton.edu>", source = ltn12.source.chain(source, filter), --server = "mail.cs.princeton.edu" server = "localhost", port = 2525 } print(r, e) -- creates a source to send a message with two parts. The first part is -- plain text, the second part is a PNG image, encoded as base64. source = smtp.message{ headers = { -- Remember that headers are *ignored* by smtp.send. from = "Sicrano <sicrano@tecgraf.puc-rio.br>", to = "Fulano <fulano@tecgraf.puc-rio.br>", subject = "Here is a message with attachments" }, body = { preamble = "If your client doesn't understand attachments, \r\n" .. "it will still display the preamble and the epilogue.\r\n" .. "Preamble might show up even in a MIME enabled client.", -- first part: No headers means plain text, us-ascii. -- The mime.eol low-level filter normalizes end-of-line markers. [1] = { body = mime.eol(0, [[ Lines in a message body should always end with CRLF. The smtp module will *NOT* perform translation. It will perform necessary stuffing, though. ]]) }, -- second part: Headers describe content the to be an image, -- sent under the base64 transfer content encoding. -- Notice that nothing happens until the message is sent. Small -- chunks are loaded into memory and translation happens on the fly. [2] = { headers = { ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"', ["content-disposition"] = 'attachment; filename="luasocket.png"', ["content-description"] = 'our logo', ["content-transfer-encoding"] = "BASE64" }, body = ltn12.source.chain( ltn12.source.file(io.open("luasocket.png", "rb")), ltn12.filter.chain( mime.encode("base64"), mime.wrap() ) ) }, epilogue = "This might also show up, but after the attachments" } } r, e = smtp.send{ rcpt = {"<diego@tecgraf.puc-rio.br>", "<diego@princeton.edu>" }, from = "<diego@princeton.edu>", source = ltn12.source.chain(source, filter), --server = "mail.cs.princeton.edu", --port = 25 server = "localhost", port = 2525 } print(r, e)
mit
Flourish-Team/Flourish
Premake/source/src/base/field.lua
15
9480
--- -- base/field.lua -- -- Fields hold a particular bit of information about a configuration, such -- as the language of a project or the list of files it uses. Each field has -- a particular data "kind", which describes the structure of the information -- it holds, such a simple string, or a list of paths. -- -- The field.* functions here manage the definition of these fields, and the -- accessor functions required to get, set, remove, and merge their values. -- -- Copyright (c) 2014 Jason Perkins and the Premake project --- local p = premake p.field = {} local field = p.field -- Lists to hold all of the registered fields and data kinds field._list = {} field._loweredList = {} field._sortedList = nil field._kinds = {} -- For historical reasons premake.fields = field._list -- A cache for data kind accessor functions field._accessors = {} --- -- Register a new field. -- -- @param f -- A table describing the new field, with these keys: -- name A unique string name for the field, to be used to identify -- the field in future operations. -- kind The kind of values that can be stored into this field. Kinds -- can be chained together to create more complex types, such as -- "list:string". -- -- In addition, any custom keys set on the field description will be -- maintained. -- -- @return -- A populated field object. Or nil and an error message if the field could -- not be registered. --- function field.new(f) -- Translate the old approaches to data kind definitions to the new -- one used here. These should probably be deprecated eventually. if f.kind:startswith("key-") then f.kind = f.kind:sub(5) f.keyed = true end if f.kind:endswith("-list") then f.kind = f.kind:sub(1, -6) f.list = true end local kind = f.kind if kind == "object" or kind == "array" then kind = "table" end if f.list then kind = "list:" .. kind end if f.keyed then kind = "keyed:" .. kind end -- Store the translated kind with a new name, so legacy add-on code -- can continue to work with the old value. f._kind = kind -- Make sure scope is always an array; don't overwrite old value if type(f.scope) == "table" then f.scopes = f.scope else f.scopes = { f.scope } end -- All fields must have a valid store() function if not field.accessor(f, "store") then return nil, "invalid field kind '" .. f._kind .. "'" end field._list[f.name] = f field._loweredList[f.name:lower()] = f field._sortedList = nil return f end --- -- Remove a previously created field definition. --- function field.unregister(f) field._list[f.name] = nil field._loweredList[f.name:lower()] = nil field._sortedList = nil end --- -- Returns an iterator for the list of registered fields; the -- ordering of returned results is arbitrary. --- function field.each() local index return function () index = next(field._list, index) return field._list[index] end end --- -- Returns an iterator for the list of registered fields; the -- results are in a prioritized order, then alphabetized. --- function field.eachOrdered() if not field._sortedList then -- no priorities yet, just alpha sort local keys = table.keys(field._list) table.sort(keys) field._sortedList = {} for i = 1, #keys do field._sortedList[i] = field._list[keys[i]] end end local i = 0 return function () i = i + 1 return field._sortedList[i] end end --- -- Register a new kind of data for field storage. -- -- @param tag -- A unique name of the kind; used in the kind string in new field -- definitions (see new(), above). -- @param settings -- A table containing the processor functions for the new kind. If -- nil, no change is made to the current field settings. -- @return -- The settings table for the specified tag. --- function field.kind(tag, settings) if settings then field._kinds[tag] = settings end return field._kinds[tag] end --- -- Build an "accessor" function to process incoming values for a field. This -- function should be an interview question. -- -- An accessor function takes the form of: -- -- function (field, current, value, nextAccessor) -- -- It receives the target field, the current value of that field, and the new -- value that has been provided by the project script. It then returns the -- new value for the target field. -- -- @param f -- The field for which an accessor should be returned. -- @param method -- The type of accessor function required; currently this should be one of -- "store", "remove", or "merge" though it is possible for add-on modules to -- extend the available methods by implementing appropriate processing -- functions. -- @return -- An accessor function for the field's kind and method. May return nil -- if no processing functions are available for the given method. --- function field.accessor(f, method) -- Prepare a cache for accessors using this method; each encountered -- kind only needs to be fully processed once. field._accessors[method] = field._accessors[method] or {} local cache = field._accessors[method] -- Helper function recurses over each piece of the field's data kind, -- building an accessor function for each sequence encountered. Results -- cached from earlier calls are reused again. local function accessorForKind(kind) -- I'll end up with a kind of "" when I hit the end of the string if kind == "" then return nil end -- Have I already cached a result from an earlier call? if cache[kind] then return cache[kind] end -- Split off the first piece from the rest of the kind. If the -- incoming kind is "list:key:string", thisKind will be "list" -- and nextKind will be "key:string". local thisKind = kind:match('(.-):') or kind local nextKind = kind:sub(#thisKind + 2) -- Get the processor function for this kind. Processors perform -- data validation and storage appropriate for the data structure. local functions = field._kinds[thisKind] if not functions then return nil, "Invalid field kind '" .. thisKind .. "'" end local processor = functions[method] if not processor then return nil end -- Now recurse to get the accessor function for the remaining parts -- of the field's data kind. If the kind was "list:key:string", then -- the processor function handles the "list" part, and this function -- takes care of the "key:string" part. local nextAccessor = accessorForKind(nextKind) -- Now here's the magic: wrap the processor and the next accessor -- up together into a Matryoshka doll of function calls, each call -- handling just it's level of the kind. accessor = function(f, current, value) return processor(f, current, value, nextAccessor) end -- And cache the result so I don't have to go through that again cache[kind] = accessor return accessor end return accessorForKind(f._kind) end function field.compare(f, a, b) local processor = field.accessor(f, "compare") if processor then return processor(f, a, b) else return (a == b) end end --- -- Fetch a field description by name. --- function field.get(name) return field._list[name] or field._loweredList[name:lower()] end function field.merge(f, current, value) local processor = field.accessor(f, "merge") if processor then return processor(f, current, value) else return value end end --- -- Is this a field that supports merging values together? Non-merging fields -- can simply overwrite their values, merging fields can call merge() to -- combine two values together. --- function field.merges(f) return (field.accessor(f, "merge") ~= nil) end --- -- Retrieve a property from a field, based on it's data kind. Allows extra -- information to be stored along with the data kind definitions; use this -- call to find the first value in the field's data kind chain. --- function field.property(f, tag) local kinds = string.explode(f._kind, ":", true) for i, kind in ipairs(kinds) do local value = field._kinds[kind][tag] if value ~= nil then return value end end end --- -- Override one of the field kind accessor functions. This works just like -- p.override(), but applies the new function to the internal field -- description and clears the accessor caches to make sure the change gets -- picked up by future operations. --- function field.override(fieldName, accessorName, func) local kind = field.kind(fieldName) p.override(kind, accessorName, func) field._accessors = {} end function field.remove(f, current, value) local processor = field.accessor(f, "remove") if processor then return processor(f, current, value) else return value end end function field.removes(f) return (field.accessor(f, "merge") ~= nil and field.accessor(f, "remove") ~= nil) end function field.store(f, current, value) local processor = field.accessor(f, "store") if processor then return processor(f, current, value) else return value end end function field.translate(f, value) local processor = field.accessor(f, "translate") if processor then return processor(f, value, nil)[1] else return value end end function field.translates(f) return (field.accessor(f, "translate") ~= nil) end
mit
hussian1997/bot-of-iraq
plugins/banhammer.lua
8
16439
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY(@AHMED_ALOBIDE) ▀▄ ▄▀ ▀▄ ▄▀ BY(@hussian_9) ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] local function pre_process(msg) local data = load_data(_config.moderation.data) -- SERVICE MESSAGE if msg.action and msg.action.type then local action = msg.action.type -- Check if banned user joins chat by link if action == 'chat_add_user_link' then local user_id = msg.from.id print('Checking invited user '..user_id) local banned = is_banned(user_id, msg.to.id) if banned or is_gbanned(user_id) then -- Check it with redis print('User is banned!') local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] is banned and kicked ! ")-- Save to logs kick_user(user_id, msg.to.id) end end -- Check if banned user joins chat if action == 'chat_add_user' then local user_id = msg.action.user.id print('Checking invited user '..user_id) local banned = is_banned(user_id, msg.to.id) if banned and not is_momod2(msg.from.id, msg.to.id) or is_gbanned(user_id) and not is_admin2(msg.from.id) then -- Check it with redis print('User is banned!') local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] added a banned user >"..msg.action.user.id)-- Save to logs kick_user(user_id, msg.to.id) local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id redis:incr(banhash) local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id local banaddredis = redis:get(banhash) if banaddredis then if tonumber(banaddredis) >= 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 3 times end if tonumber(banaddredis) >= 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 7 times local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id redis:set(banhash, 0)-- Reset the Counter end end end if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings'] then if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end end end if msg.action.user.username ~= nil then if string.sub(msg.action.user.username:lower(), -3) == 'bot' and not is_momod(msg) and bots_protection == "yes" then --- Will kick bots added by normal users local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] added a bot > @".. msg.action.user.username)-- Save to logs kick_user(msg.action.user.id, msg.to.id) end end end -- No further checks return msg end -- banned user is talking ! if msg.to.type == 'chat' or msg.to.type == 'channel' then local group = msg.to.id local texttext = 'groups' --if not data[tostring(texttext)][tostring(msg.to.id)] and not is_realm(msg) then -- Check if this group is one of my groups or not --chat_del_user('chat#id'..msg.to.id,'user#id'..our_id,ok_cb,false) --return --end local user_id = msg.from.id local chat_id = msg.to.id local banned = is_banned(user_id, chat_id) if banned or is_gbanned(user_id) then -- Check it with redis print('Banned user talking!') local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] banned user is talking !")-- Save to logs kick_user(user_id, chat_id) msg.text = '' end end return msg end local function banall_by_reply(extra, success, result) if result.to.peer_type == 'chat' or result.to.peer_type == 'channel' then local chat = 'chat#id'..result.to.peer_id local channel = 'channel#id'..result.to.peer_id if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(result.from.peer_id) then -- Ignore admins return end banall_user(result.from.peer_id) send_large_msg(chat, "User "..result.from.peer_id.." Golobally Banned") send_large_msg(channel, "User "..result.from.peer_id.." Golobally Banned") else return end end local function unbanall_by_reply(extra, success, result) if result.to.peer_type == 'chat' or result.to.peer_type == 'channel' then local user_id = result.from.peer_id local chat = 'chat#id'..result.to.peer_id local channel = 'channel#id'..result.to.peer_id if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(result.from.peer_id) then -- Ignore admins return end if is_gbanned(result.from.peer_id) then return result.from.peer_id..' is already un-Gbanned.' end if not is_gbanned(result.from.peer_id) then unbanall_user(result.from.peer_id) send_large_msg(chat, "User "..result.from.peer_id.." Golobally un-Banned") send_large_msg(channel, "User "..result.from.peer_id.." Golobally un-Banned") end end end local function unban_by_reply(extra, success, result) if result.to.peer_type == 'chat' or result.to.peer_type == 'channel' then local chat = 'chat#id'..result.to.peer_id local channel = 'channel#id'..result.to.peer_id if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot return end if is_admin2(result.from.peer_id) then -- Ignore admins return end send_large_msg(chat, "User "..result.from.peer_id.." un-Banned") send_large_msg(channel, "User "..result.from.peer_id.." un-Banned") local hash = 'banned:'..result.to.peer_id redis:srem(hash, result.from.peer_id) else return end end local function kick_ban_res(extra, success, result) local chat_id = extra.chat_id local chat_type = extra.chat_type if chat_type == "chat" then receiver = 'chat#id'..chat_id else receiver = 'channel#id'..chat_id end if success == 0 then return send_large_msg(receiver, "Cannot find user by that username!") end local member_id = result.peer_id local user_id = member_id local member = result.username local from_id = extra.from_id local get_cmd = extra.get_cmd if get_cmd == "kick" then if member_id == from_id then send_large_msg(receiver, "You can't kick yourself") return end if is_momod2(member_id, chat_id) and not is_admin2(sender) then send_large_msg(receiver, "You can't kick mods/owner/admins") return end kick_user(member_id, chat_id) elseif get_cmd == 'ban' then if is_momod2(member_id, chat_id) and not is_admin2(sender) then send_large_msg(receiver, "You can't ban mods/owner/admins") return end send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned') ban_user(member_id, chat_id) elseif get_cmd == 'unban' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned') local hash = 'banned:'..chat_id redis:srem(hash, member_id) return 'User '..user_id..' unbanned' elseif get_cmd == 'banall' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned') banall_user(member_id) elseif get_cmd == 'unbanall' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally unbanned') unbanall_user(member_id) end end local function run(msg, matches) local support_id = msg.from.id if matches[1]:lower() == 'id' and msg.to.type == "chat" or msg.to.type == "user" then if msg.to.type == "user" then return "Your id : "..msg.from.id end if type(msg.reply_id) ~= "nil" then local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") id = get_message(msg.reply_id,get_message_callback_id, false) elseif matches[1]:lower() == 'id' then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") local text = "_🇮🇷 Group ID : _*"..msg.to.id.."*\n_🇮🇷 Group Name : _*"..msg.to.title.."*" send_api_msg(msg, get_receiver_api(msg), text, true, 'md') end end if matches[1]:lower() == 'kickme' and msg.to.type == "chat" then-- /kickme local receiver = get_receiver(msg) if msg.to.type == 'chat' then local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] left using kickme ")-- Save to logs chat_del_user("chat#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) end end if not is_momod(msg) then -- Ignore normal users return end if matches[1]:lower() == "banlist" then -- Ban list ! local chat_id = msg.to.id if matches[2] and is_admin1(msg) then chat_id = matches[2] end return ban_list(chat_id) end if matches[1]:lower() == 'ban' then-- /ban if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin1(msg) then msgr = get_message(msg.reply_id,ban_by_reply_admins, false) else msgr = get_message(msg.reply_id,ban_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id elseif string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then return "you can't ban mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't ban your self !" end local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") local receiver = get_receiver(msg) savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2]) ban_user(matches[2], msg.to.id) send_large_msg(receiver, 'User ['..matches[2]..'] banned') else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'ban', from_id = msg.from.id, chat_type = msg.to.type } local username = string.gsub(matches[2], '@', '') resolve_username(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'kick' then if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin1(msg) then msgr = get_message(msg.reply_id,Kick_by_reply_admins, false) else msgr = get_message(msg.reply_id,Kick_by_reply, false) end elseif string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then return "you can't kick mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't kick your self !" end local user_id = matches[2] local chat_id = msg.to.id local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2]) kick_user(user_id, chat_id) else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'kick', from_id = msg.from.id, chat_type = msg.to.type } local username = string.gsub(matches[2], '@', '') resolve_username(username, kick_ban_res, cbres_extra) end end if not is_admin1(msg) and not is_support(support_id) then return end if matches[1]:lower() == 'banall' then-- /ban if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin1(msg) then msgr = get_message(msg.reply_id,banall_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id elseif string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then return "you can't ban mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't ban your self !" end local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") local receiver = get_receiver(msg) savelog(msg.to.id, name.." ["..msg.from.id.."] banedall user ".. matches[2]) banall_user(matches[2]) send_large_msg(receiver, 'User ['..matches[2]..'] bannedalled') else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'banall', from_id = msg.from.id, chat_type = msg.to.type } local username = string.gsub(matches[2], '@', '') resolve_username(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'unbanall' then-- /ban if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin1(msg) then msgr = get_message(msg.reply_id,unbanall_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id elseif string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then return "you can't ban mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't ban your self !" end local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") local receiver = get_receiver(msg) savelog(msg.to.id, name.." ["..msg.from.id.."] unbanedall user ".. matches[2]) unbanall_user(matches[2]) send_large_msg(receiver, 'User ['..matches[2]..'] unbannedalled') else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'unbanall', from_id = msg.from.id, chat_type = msg.to.type } local username = string.gsub(matches[2], '@', '') resolve_username(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'unban' then-- /ban if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin1(msg) then msgr = get_message(msg.reply_id,unban_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id elseif string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end local print_name = user_print_name(msg.from):gsub("‮", "") local name = print_name:gsub("_", "") local receiver = get_receiver(msg) savelog(msg.to.id, name.." ["..msg.from.id.."] unban user ".. matches[2]) unbanall_user(matches[2]) send_large_msg(receiver, 'User ['..matches[2]..'] unbanned') else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'unban', from_id = msg.from.id, chat_type = msg.to.type } local username = string.gsub(matches[2], '@', '') resolve_username(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == "gbanlist" then -- Global ban list return banall_list() end end return { patterns = { "^[#!/]([Bb]anall) (.*)$", "^[#!/]([Bb]anall)$", "^[#!/]([Uu]ubanall)$", "^[#!/]([Bb]anlist) (.*)$", "^[#!/]([Bb]anlist)$", "^[#!/]([Gg]banlist)$", "^[#!/]([Kk]ickme)", "^[#!/]([Kk]ick)$", "^[#!/]([Bb]an)$", "^[#!/]([Bb]an) (.*)$", "^[#!/]([Uu]nban) (.*)$", "^[#!/]([Uu]nbanall) (.*)$", "^[#!/]([Uu]nbanall)$", "^[#!/]([Kk]ick) (.*)$", "^[#!/]([Uu]nban)$", "^[#!/]([Ii]d)$", "^!!tgservice (.+)$" }, run = run, pre_process = pre_process }
agpl-3.0
kidaa/lua-path
lua/path/win32/fs.lua
3
35241
--[[ note GetTempPath GetTempPath() might ignore the environment variables it's supposed to use (TEMP, TMP, ...) if they are more than 130 characters or so. http://blogs.msdn.com/b/larryosterman/archive/2010/10/19/because-if-you-do_2c00_-stuff-doesn_2700_t-work-the-way-you-intended_2e00_.aspx --------------- Limit of Buffer Size for GetTempPath [Note - this behavior does not occur with the latest versions of the OS as of Vista SP1/Windows Server 2008. If anyone has more information about when this condition occurs, please update this content.] [Note - this post has been edited based on, and extended by, information in the following post] Apparently due to the method used by GetTempPathA to translate ANSI strings to UNICODE, this function itself cannot be told that the buffer is greater than 32766 in narrow convention. Attempting to pass a larger value in nBufferLength will result in a failed RtlHeapFree call in ntdll.dll and subsequently cause your application to call DbgBreakPoint in debug compiles and simple close without warning in release compiles. Example: // Allocate a 32Ki character buffer, enough to hold even native NT paths. LPTSTR tempPath = new TCHAR[32767]; ::GetTempPath(32767, tempPath); // Will crash in RtlHeapFree ---------------- --]] local function prequire(...) local ok, mod = pcall(require, ...) if not ok then return nil, mod end return mod end local lua_version do local lua_version_t lua_version = function() if not lua_version_t then local version = assert(_VERSION) local maj, min = version:match("^Lua (%d+)%.(%d+)$") if maj then lua_version_t = {tonumber(maj),tonumber(min)} elseif math.type then lua_version_t = {5,3} elseif not math.mod then lua_version_t = {5,2} elseif table.pack and not pack then lua_version_t = {5,2} else lua_version_t = {5,2} end end return lua_version_t[1], lua_version_t[2] end end local LUA_MAJOR, LUA_MINOR = lua_version() local LUA_VER_NUM = LUA_MAJOR * 100 + LUA_MINOR local load_bit if LUA_VER_NUM < 503 then load_bit = function() return assert(prequire("bit32") or prequire("bit")) end else load_bit = function () local bit_loader = assert(load[[ return { band = function(a, b) return a & b end; } ]]) return assert(bit_loader()) end end local bit = load_bit() local CONST = { GENERIC_READ = 0x80000000; GENERIC_WRITE = 0x40000000; GENERIC_EXECUTE = 0x20000000; GENERIC_ALL = 0x10000000; FILE_FLAG_WRITE_THROUGH = 0x80000000; FILE_FLAG_NO_BUFFERING = 0x20000000; FILE_FLAG_RANDOM_ACCESS = 0x10000000; FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000; FILE_FLAG_DELETE_ON_CLOSE = 0x04000000; FILE_FLAG_OVERLAPPED = 0x40000000; FILE_ATTRIBUTE_ARCHIVE = 0x00000020; -- A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or removal . FILE_ATTRIBUTE_COMPRESSED = 0x00000800; -- A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories. FILE_ATTRIBUTE_DEVICE = 0x00000040; -- This value is reserved for system use. FILE_ATTRIBUTE_DIRECTORY = 0x00000010; -- The handle that identifies a directory. FILE_ATTRIBUTE_ENCRYPTED = 0x00004000; -- A file or directory that is encrypted. For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories. FILE_ATTRIBUTE_HIDDEN = 0x00000002; -- The file or directory is hidden. It is not included in an ordinary directory listing. FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000; -- The directory or user data stream is configured with integrity (only supported on ReFS volumes). It is not included in an ordinary directory listing. The integrity setting persists with the file if it's renamed. If a file is copied the destination file will have integrity set if either the source file or destination directory have integrity set. (This flag is not supported until Windows Server 2012.) FILE_ATTRIBUTE_NORMAL = 0x00000080; -- A file that does not have other attributes set. This attribute is valid only when used alone. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000; -- The file or directory is not to be indexed by the content indexing service. FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000; -- The user data stream not to be read by the background data integrity scanner (AKA scrubber). When set on a directory it only provides inheritance. This flag is only supported on Storage Spaces and ReFS volumes. It is not included in an ordinary directory listing. This flag is not supported until Windows 8 and Windows Server 2012. FILE_ATTRIBUTE_OFFLINE = 0x00001000; -- The data of a file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute. FILE_ATTRIBUTE_READONLY = 0x00000001; -- A file that is read-only. Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories. For more information, see You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, in Windows Vista or in Windows 7. FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400; -- A file or directory that has an associated reparse point, or a file that is a symbolic link. FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200; -- A file that is a sparse file. FILE_ATTRIBUTE_SYSTEM = 0x00000004; -- A file or directory that the operating system uses a part of, or uses exclusively. FILE_ATTRIBUTE_TEMPORARY = 0x00000100; -- A file that is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed. FILE_ATTRIBUTE_VIRTUAL = 0x00010000; -- FILE_READ_DATA = 0x00000001; -- file & pipe FILE_LIST_DIRECTORY = 0x00000001; -- directory FILE_WRITE_DATA = 0x00000002; -- file & pipe FILE_ADD_FILE = 0x00000002; -- directory FILE_APPEND_DATA = 0x00000004; -- file FILE_ADD_SUBDIRECTORY = 0x00000004; -- directory FILE_CREATE_PIPE_INSTANCE = 0x00000004; -- named pipe FILE_READ_EA = 0x00000008; -- file & directory FILE_WRITE_EA = 0x00000010; -- file & directory FILE_EXECUTE = 0x00000020; -- file FILE_TRAVERSE = 0x00000020; -- directory FILE_DELETE_CHILD = 0x00000040; -- directory FILE_READ_ATTRIBUTES = 0x00000080; -- all FILE_WRITE_ATTRIBUTES = 0x00000100; -- all FILE_SHARE_READ = 0x00000001; FILE_SHARE_WRITE = 0x00000002; FILE_SHARE_DELETE = 0x00000004; CREATE_NEW = 1; CREATE_ALWAYS = 2; OPEN_EXISTING = 3; OPEN_ALWAYS = 4; TRUNCATE_EXISTING = 5; FILE_DEVICE_8042_PORT = 0x00000027; FILE_DEVICE_ACPI = 0x00000032; FILE_DEVICE_BATTERY = 0x00000029; FILE_DEVICE_BEEP = 0x00000001; FILE_DEVICE_BUS_EXTENDER = 0x0000002a; FILE_DEVICE_CD_ROM = 0x00000002; FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003; FILE_DEVICE_CHANGER = 0x00000030; FILE_DEVICE_CONTROLLER = 0x00000004; FILE_DEVICE_DATALINK = 0x00000005; FILE_DEVICE_DFS = 0x00000006; FILE_DEVICE_DFS_FILE_SYSTEM = 0x00000035; FILE_DEVICE_DFS_VOLUME = 0x00000036; FILE_DEVICE_DISK = 0x00000007; FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008; FILE_DEVICE_DVD = 0x00000033; FILE_DEVICE_FILE_SYSTEM = 0x00000009; FILE_DEVICE_FIPS = 0x0000003a; FILE_DEVICE_FULLSCREEN_VIDEO = 0x00000034; FILE_DEVICE_INPORT_PORT = 0x0000000a; FILE_DEVICE_KEYBOARD = 0x0000000b; FILE_DEVICE_KS = 0x0000002f; FILE_DEVICE_KSEC = 0x00000039; FILE_DEVICE_MAILSLOT = 0x0000000c; FILE_DEVICE_MASS_STORAGE = 0x0000002d; FILE_DEVICE_MIDI_IN = 0x0000000d; FILE_DEVICE_MIDI_OUT = 0x0000000e; FILE_DEVICE_MODEM = 0x0000002b; FILE_DEVICE_MOUSE = 0x0000000f; FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010; FILE_DEVICE_NAMED_PIPE = 0x00000011; FILE_DEVICE_NETWORK = 0x00000012; FILE_DEVICE_NETWORK_BROWSER = 0x00000013; FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014; FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028; FILE_DEVICE_NULL = 0x00000015; FILE_DEVICE_PARALLEL_PORT = 0x00000016; FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017; FILE_DEVICE_PRINTER = 0x00000018; FILE_DEVICE_SCANNER = 0x00000019; FILE_DEVICE_SCREEN = 0x0000001c; FILE_DEVICE_SERENUM = 0x00000037; FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001a; FILE_DEVICE_SERIAL_PORT = 0x0000001b; FILE_DEVICE_SMARTCARD = 0x00000031; FILE_DEVICE_SMB = 0x0000002e; FILE_DEVICE_SOUND = 0x0000001d; FILE_DEVICE_STREAMS = 0x0000001e; FILE_DEVICE_TAPE = 0x0000001f; FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020; FILE_DEVICE_TERMSRV = 0x00000038; FILE_DEVICE_TRANSPORT = 0x00000021; FILE_DEVICE_UNKNOWN = 0x00000022; FILE_DEVICE_VDM = 0x0000002c; FILE_DEVICE_VIDEO = 0x00000023; FILE_DEVICE_VIRTUAL_DISK = 0x00000024; FILE_DEVICE_WAVE_IN = 0x00000025; FILE_DEVICE_WAVE_OUT = 0x00000026; -- If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions. -- If the file is successfully copied to a different volume and the original file is unable to be deleted, the function succeeds leaving the source file intact. -- This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT. MOVEFILE_COPY_ALLOWED = 0x00000002; -- Reserved for future use. MOVEFILE_CREATE_HARDLINK = 0x00000010; -- The system does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups. -- This value can be used only if the process is in the context of a user who belongs to the administrators group or the LocalSystem account. -- This value cannot be used with MOVEFILE_COPY_ALLOWED. -- Windows Server 2003 and Windows XP: For information about special situations where this functionality can fail, and a suggested workaround solution, see Files are not exchanged when Windows Server 2003 restarts if you use the MoveFileEx function to schedule a replacement for some files in the Help and Support Knowledge Base. MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004; -- The function fails if the source file is a link source, but the file cannot be tracked after the move. This situation can occur if the destination is a volume formatted with the FAT file system. MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020; -- If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file, provided that security requirements regarding access control lists (ACLs) are met. For more information, see the Remarks section of this topic. -- This value cannot be used if lpNewFileName or lpExistingFileName names a directory. MOVEFILE_REPLACE_EXISTING = 0x00000001; -- The function does not return until the file is actually moved on the disk. -- Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation. -- This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set. MOVEFILE_WRITE_THROUGH = 0x00000008; LANG_NEUTRAL = 0x00; LANG_AFRIKAANS = 0x36; LANG_ALBANIAN = 0x1c; LANG_ARABIC = 0x01; LANG_BASQUE = 0x2d; LANG_BELARUSIAN = 0x23; LANG_BULGARIAN = 0x02; LANG_CATALAN = 0x03; LANG_CHINESE = 0x04; LANG_CROATIAN = 0x1a; LANG_CZECH = 0x05; LANG_DANISH = 0x06; LANG_DUTCH = 0x13; LANG_ENGLISH = 0x09; LANG_ESTONIAN = 0x25; LANG_FAEROESE = 0x38; LANG_FARSI = 0x29; LANG_FINNISH = 0x0b; LANG_FRENCH = 0x0c; LANG_GERMAN = 0x07; LANG_GREEK = 0x08; LANG_HEBREW = 0x0d; LANG_HINDI = 0x39; LANG_HUNGARIAN = 0x0e; LANG_ICELANDIC = 0x0f; LANG_INDONESIAN = 0x21; LANG_ITALIAN = 0x10; LANG_JAPANESE = 0x11; LANG_KOREAN = 0x12; LANG_LATVIAN = 0x26; LANG_LITHUANIAN = 0x27; LANG_MACEDONIAN = 0x2f; LANG_MALAY = 0x3e; LANG_NORWEGIAN = 0x14; LANG_POLISH = 0x15; LANG_PORTUGUESE = 0x16; LANG_ROMANIAN = 0x18; LANG_RUSSIAN = 0x19; LANG_SERBIAN = 0x1a; LANG_SLOVAK = 0x1b; LANG_SLOVENIAN = 0x24; LANG_SPANISH = 0x0a; LANG_SWAHILI = 0x41; LANG_SWEDISH = 0x1d; LANG_THAI = 0x1e; LANG_TURKISH = 0x1f; LANG_UKRAINIAN = 0x22; LANG_VIETNAMESE = 0x2a; SUBLANG_NEUTRAL = 0x00; -- language neutral SUBLANG_DEFAULT = 0x01; -- user default SUBLANG_SYS_DEFAULT = 0x02; -- system default SUBLANG_ARABIC_SAUDI_ARABIA = 0x01; -- Arabic (Saudi Arabia) SUBLANG_ARABIC_IRAQ = 0x02; -- Arabic (Iraq) SUBLANG_ARABIC_EGYPT = 0x03; -- Arabic (Egypt) SUBLANG_ARABIC_LIBYA = 0x04; -- Arabic (Libya) SUBLANG_ARABIC_ALGERIA = 0x05; -- Arabic (Algeria) SUBLANG_ARABIC_MOROCCO = 0x06; -- Arabic (Morocco) SUBLANG_ARABIC_TUNISIA = 0x07; -- Arabic (Tunisia) SUBLANG_ARABIC_OMAN = 0x08; -- Arabic (Oman) SUBLANG_ARABIC_YEMEN = 0x09; -- Arabic (Yemen) SUBLANG_ARABIC_SYRIA = 0x0a; -- Arabic (Syria) SUBLANG_ARABIC_JORDAN = 0x0b; -- Arabic (Jordan) SUBLANG_ARABIC_LEBANON = 0x0c; -- Arabic (Lebanon) SUBLANG_ARABIC_KUWAIT = 0x0d; -- Arabic (Kuwait) SUBLANG_ARABIC_UAE = 0x0e; -- Arabic (U.A.E) SUBLANG_ARABIC_BAHRAIN = 0x0f; -- Arabic (Bahrain) SUBLANG_ARABIC_QATAR = 0x10; -- Arabic (Qatar) SUBLANG_CHINESE_TRADITIONAL = 0x01; -- Chinese (Taiwan Region) SUBLANG_CHINESE_SIMPLIFIED = 0x02; -- Chinese (PR China) SUBLANG_CHINESE_HONGKONG = 0x03; -- Chinese (Hong Kong) SUBLANG_CHINESE_SINGAPORE = 0x04; -- Chinese (Singapore) SUBLANG_CHINESE_MACAU = 0x05; -- Chinese (Macau) SUBLANG_DUTCH = 0x01; -- Dutch SUBLANG_DUTCH_BELGIAN = 0x02; -- Dutch (Belgian) SUBLANG_ENGLISH_US = 0x01; -- English (USA) SUBLANG_ENGLISH_UK = 0x02; -- English (UK) SUBLANG_ENGLISH_AUS = 0x03; -- English (Australian) SUBLANG_ENGLISH_CAN = 0x04; -- English (Canadian) SUBLANG_ENGLISH_NZ = 0x05; -- English (New Zealand) SUBLANG_ENGLISH_EIRE = 0x06; -- English (Irish) SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07; -- English (South Africa) SUBLANG_ENGLISH_JAMAICA = 0x08; -- English (Jamaica) SUBLANG_ENGLISH_CARIBBEAN = 0x09; -- English (Caribbean) SUBLANG_ENGLISH_BELIZE = 0x0a; -- English (Belize) SUBLANG_ENGLISH_TRINIDAD = 0x0b; -- English (Trinidad) SUBLANG_ENGLISH_ZIMBABWE = 0x0c; -- English (Zimbabwe) SUBLANG_ENGLISH_PHILIPPINES = 0x0d; -- English (Philippines) SUBLANG_FRENCH = 0x01; -- French SUBLANG_FRENCH_BELGIAN = 0x02; -- French (Belgian) SUBLANG_FRENCH_CANADIAN = 0x03; -- French (Canadian) SUBLANG_FRENCH_SWISS = 0x04; -- French (Swiss) SUBLANG_FRENCH_LUXEMBOURG = 0x05; -- French (Luxembourg) SUBLANG_FRENCH_MONACO = 0x06; -- French (Monaco) SUBLANG_GERMAN = 0x01; -- German SUBLANG_GERMAN_SWISS = 0x02; -- German (Swiss) SUBLANG_GERMAN_AUSTRIAN = 0x03; -- German (Austrian) SUBLANG_GERMAN_LUXEMBOURG = 0x04; -- German (Luxembourg) SUBLANG_GERMAN_LIECHTENSTEIN = 0x05; -- German (Liechtenstein) SUBLANG_ITALIAN = 0x01; -- Italian SUBLANG_ITALIAN_SWISS = 0x02; -- Italian (Swiss) SUBLANG_KOREAN = 0x01; -- Korean (Extended Wansung) SUBLANG_KOREAN_JOHAB = 0x02; -- Korean (Johab) SUBLANG_LITHUANIAN = 0x01; -- Lithuanian SUBLANG_LITHUANIAN_CLASSIC = 0x02; -- Lithuanian (Classic) SUBLANG_MALAY_MALAYSIA = 0x01; -- Malay (Malaysia) SUBLANG_MALAY_BRUNEI_DARUSSALAM = 0x02; -- Malay (Brunei Darussalam) SUBLANG_NORWEGIAN_BOKMAL = 0x01; -- Norwegian (Bokmal) SUBLANG_NORWEGIAN_NYNORSK = 0x02; -- Norwegian (Nynorsk) SUBLANG_PORTUGUESE = 0x02; -- Portuguese SUBLANG_PORTUGUESE_BRAZILIAN = 0x01; -- Portuguese (Brazilian) SUBLANG_SERBIAN_LATIN = 0x02; -- Serbian (Latin) SUBLANG_SERBIAN_CYRILLIC = 0x03; -- Serbian (Cyrillic) SUBLANG_SPANISH = 0x01; -- Spanish (Castilian) SUBLANG_SPANISH_MEXICAN = 0x02; -- Spanish (Mexican) SUBLANG_SPANISH_MODERN = 0x03; -- Spanish (Modern) SUBLANG_SPANISH_GUATEMALA = 0x04; -- Spanish (Guatemala) SUBLANG_SPANISH_COSTA_RICA = 0x05; -- Spanish (Costa Rica) SUBLANG_SPANISH_PANAMA = 0x06; -- Spanish (Panama) SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07; -- Spanish (Dominican Republic) SUBLANG_SPANISH_VENEZUELA = 0x08; -- Spanish (Venezuela) SUBLANG_SPANISH_COLOMBIA = 0x09; -- Spanish (Colombia) SUBLANG_SPANISH_PERU = 0x0a; -- Spanish (Peru) SUBLANG_SPANISH_ARGENTINA = 0x0b; -- Spanish (Argentina) SUBLANG_SPANISH_ECUADOR = 0x0c; -- Spanish (Ecuador) SUBLANG_SPANISH_CHILE = 0x0d; -- Spanish (Chile) SUBLANG_SPANISH_URUGUAY = 0x0e; -- Spanish (Uruguay) SUBLANG_SPANISH_PARAGUAY = 0x0f; -- Spanish (Paraguay) SUBLANG_SPANISH_BOLIVIA = 0x10; -- Spanish (Bolivia) SUBLANG_SPANISH_EL_SALVADOR = 0x11; -- Spanish (El Salvador) SUBLANG_SPANISH_HONDURAS = 0x12; -- Spanish (Honduras) SUBLANG_SPANISH_NICARAGUA = 0x13; -- Spanish (Nicaragua) SUBLANG_SPANISH_PUERTO_RICO = 0x14; -- Spanish (Puerto Rico) SUBLANG_SWEDISH = 0x01; -- Swedish SUBLANG_SWEDISH_FINLAND = 0x02; -- Swedish (Finland) -- The system cannot find the file specified. ERROR_FILE_NOT_FOUND = 2; -- 0x00000002 -- The system cannot find the path specified. ERROR_PATH_NOT_FOUND = 3; -- 0x00000003 -- Cannot create a file when that file already exists. ERROR_ALREADY_EXISTS = 183; -- 0x000000B7 } local function lshift(v, n) return math.floor(v * (2 ^ n)) end local function rshift(v, n) return math.floor(v / (2 ^ n)) end local function FileTimeToTimeT(low, high) return math.floor(low / 10000000 + high * (2^32 / 10000000)) - 11644473600; end local function TimeTToFileTime(v) v = 10000000 * (v + 11644473600) local high = rshift(v,32) local low = v - lshift(high, 32) return low, high end local function LargeToNumber(low, high) return low + high * 2^32 end local function TestBit(flags, flag) return (0 ~= bit.band(flags, flag)) end local function AttributesToStat(fd) local flags = fd.dwFileAttributes; local ctime = FileTimeToTimeT(fd.ftCreationTime.dwLowDateTime, fd.ftCreationTime.dwHighDateTime); local atime = FileTimeToTimeT(fd.ftLastAccessTime.dwLowDateTime, fd.ftLastAccessTime.dwHighDateTime); local mtime = FileTimeToTimeT(fd.ftLastWriteTime.dwLowDateTime, fd.ftLastWriteTime.dwHighDateTime); local size = LargeToNumber (fd.nFileSizeLow, fd.nFileSizeHigh); local mode if TestBit(flags, CONST.FILE_ATTRIBUTE_REPARSE_POINT) then mode = "link" elseif TestBit(flags, CONST.FILE_ATTRIBUTE_DIRECTORY) then mode = "directory" else mode = "file" end return{ mode = mode; nlink = 1; -- number of hard links to the file uid = 0; -- user-id of owner (Unix only, always 0 on Windows) gid = 0; -- group-id of owner (Unix only, always 0 on Windows) ino = 0; access = atime; modification = mtime; change = ctime; size = size; } end local function FlagsToMode(flags) if TestBit(flags, CONST.FILE_ATTRIBUTE_REPARSE_POINT) then return "link" end if TestBit(flags, CONST.FILE_ATTRIBUTE_DIRECTORY) then return "directory" end return "file" end local function AttributesToStat2(fd) local flags = fd.dwFileAttributes; local ctime = FileTimeToTimeT( fd.ftCreationTime[1], fd.ftCreationTime[2] ); local atime = FileTimeToTimeT( fd.ftLastAccessTime[1], fd.ftLastAccessTime[2] ); local mtime = FileTimeToTimeT( fd.ftLastWriteTime[1], fd.ftLastWriteTime[2] ); local size = LargeToNumber ( fd.nFileSize[1], fd.nFileSize[2] ); local mode = FlagsToMode(flags) return{ mode = mode; nlink = 1; -- number of hard links to the file uid = 0; -- user-id of owner (Unix only, always 0 on Windows) gid = 0; -- group-id of owner (Unix only, always 0 on Windows) ino = 0; access = atime; modification = mtime; change = ctime; size = size; } end local function clone(t, o) if not o then o = {} end for k, v in pairs(t) do o[k] = v end return o end local _M = {} function _M.currentdir(u) return u.GetCurrentDirectory() end function _M.attributes(u, P, a) --- @todo On Windows systems, represents the drive number of the disk containing the file local dev = 0 --- @todo decode only one attribute if `a` provided local attr, err = u.GetFileAttributesEx(P) if not attr then return nil, err end local stat = AttributesToStat(attr) stat.dev, stat.rdev = dev, dev if a then return stat[a] end return stat end function _M.flags(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then return nil, err end return fd.dwFileAttributes end function _M.ctime(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then return nil, err end return FileTimeToTimeT(fd.ftCreationTime.dwLowDateTime, fd.ftCreationTime.dwHighDateTime) end function _M.atime(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then return nil, err end return FileTimeToTimeT(fd.ftLastAccessTime.dwLowDateTime, fd.ftLastAccessTime.dwHighDateTime) end function _M.mtime(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then return nil, err end return FileTimeToTimeT(fd.ftLastWriteTime.dwLowDateTime, fd.ftLastWriteTime.dwHighDateTime) end function _M.size(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then return nil, err end return LargeToNumber (fd.nFileSizeLow, fd.nFileSizeHigh); end local function file_not_found(err) return (err == CONST.ERROR_FILE_NOT_FOUND) or (err == CONST.ERROR_PATH_NOT_FOUND) end function _M.exists(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then if file_not_found(err) then return false end return nil, err end return P end function _M.isdir(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then if file_not_found(err) then return false end return nil, err end if TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_REPARSE_POINT) then return false end return TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_DIRECTORY) and P end function _M.isfile(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then if file_not_found(err) then return false end return nil, err end if TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_REPARSE_POINT) then return false end return (not TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_DIRECTORY)) and P end function _M.islink(u, P) local fd, err = u.GetFileAttributesEx(P) if not fd then if file_not_found(err) then return false end return nil, err end return TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_REPARSE_POINT) end function _M.mkdir(u, P) local ok, err = u.CreateDirectory(P) if not ok then -- if err == CONST.ERROR_ALREADY_EXISTS then return false end return ok, err end return ok end function _M.rmdir(u, P) return u.RemoveDirectory(P) end function _M.chdir(u, P) return u.SetCurrentDirectory(P) end function _M.copy(u, src, dst, force) return u.CopyFile(src, dst, not force) end function _M.move(u, src, dst, flags) if flags == nil then flags = CONST.MOVEFILE_COPY_ALLOWED elseif flags == true then flags = CONST.MOVEFILE_COPY_ALLOWED + CONST.MOVEFILE_REPLACE_EXISTING end return u.MoveFileEx(src, dst, flags) end function _M.remove(u, P) return u.DeleteFile(P) end function _M.tmpdir(u) return u.GetTempPath() end function _M.link() return nil, "make_link is not supported on Windows"; end function _M.setmode() return nil, "setmode is not supported by this implementation"; end function _M.dir(u, P) local h, fd = u.FindFirstFile(P .. u.DIR_SEP .. u.ANY_MASK) if not h then local nop = function()end if (fd == CONST.ERROR_FILE_NOT_FOUND) or (fd == CONST.ERROR_PATH_NOT_FOUND) then -- this is not error but just empty result return nop, {close = nop} end return function() return nil, fd end, {close = nop} end local closed = false local obj = { close = function(self) if not h then return end u.FindClose(h) h, closed = nil, true end; next = function(self) if not h then if not closed then closed = true return end error("calling 'next' on bad self (closed directory)", 2) end local fname = u.WIN32_FIND_DATA2TABLE(fd).cFileName local ret, err = u.FindNextFile(h, fd) if ret == 0 then self:close() closed = false end return fname end } return obj.next, obj end function _M.touch(u, P, at, mt) if not at then at = os.time() end if not mt then mt = at end local atime = {TimeTToFileTime(at)} local mtime = {TimeTToFileTime(mt)} local h, err = u.CreateFile(P, CONST.GENERIC_READ + CONST.FILE_WRITE_ATTRIBUTES, CONST.FILE_SHARE_READ + CONST.FILE_SHARE_WRITE, nil, CONST.OPEN_EXISTING, CONST.FILE_ATTRIBUTE_NORMAL, nil ) if not h then return nil, err end local ok, err = u.SetFileTime(h, nil, atime, mtime) u.CloseHandle(h) if not ok then return nil, err end return ok end local function findfile(u, P, cb) local h, fd = u.FindFirstFile(P) if not h then if (fd == CONST.ERROR_FILE_NOT_FOUND) or (fd == CONST.ERROR_PATH_NOT_FOUND) then -- this is not error but just empty result return end return nil, fd end repeat local ret = cb(fd) if ret then u.FindClose(h) return ret end ret = u.FindNextFile(h, fd) until ret == 0; u.FindClose(h) end local function isdots(P) return P == '.' or P == '..' or P == '.\0' or P == '.\0.\0' end local function find_last(str, sub) local pos = nil while true do local next_pos = string.find(str, sub, pos, true) if not next_pos then return pos end pos = next_pos + #sub end end local function splitpath(P, sep) local pos = find_last(P, sep) if not pos then return "", P end return string.sub(P, 1, pos - #sep - 1), string.sub(P, pos) end local foreach_impl local function do_foreach_recurse(u, base, mask, callback, option) return findfile(u, base .. u.DIR_SEP .. u.ANY_MASK, function(fd) if not TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_DIRECTORY) then return end if option.skiplinks and TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_REPARSE_POINT) then return end fd = u.WIN32_FIND_DATA2TABLE(fd) if isdots(fd.cFileName) then return end return foreach_impl(u, base .. u.DIR_SEP .. fd.cFileName, mask, callback, option) end) end foreach_impl = function (u, base, mask, callback, option) local path = base .. u.DIR_SEP if option.recurse and option.reverse then local res, err = do_foreach_recurse(u, base, mask, callback, option) if res or err then return res, err end end local tmp, origin_cb if option.delay then tmp, origin_cb, callback = {}, callback, function(base,name,fd) table.insert(tmp, {base,name,fd}) end; end local ok, err = findfile(u, path .. mask, function(fd) local isdir = TestBit(fd.dwFileAttributes, CONST.FILE_ATTRIBUTE_DIRECTORY) if isdir then if option.skipdirs then return end else if option.skipfiles then return end end fd = u.WIN32_FIND_DATA2TABLE(fd) if isdir and option.skipdots ~= false and isdots(fd.cFileName) then return end return callback(base, fd.cFileName, fd) end) if ok or err then return ok, err end if option.delay then for _, t in pairs(tmp) do local ok, err = origin_cb(t[1], t[2], t[3]) if ok or err then return ok, err end end end if option.recurse and not option.reverse then local res, err = do_foreach_recurse(u, base, mask, origin_cb or callback, option) if res or err then return res, err end end end function _M.foreach(u, base, callback, option) local base, mask = splitpath(base, u.DIR_SEP) if mask == '' then mask = u.ANY_MASK end return foreach_impl(u, base, mask, function(base, name, fd) return callback(base .. u.DIR_SEP .. name, AttributesToStat2(fd)) end, option or {}) end local attribs = { f = function(u, base, name, fd) return base..u.DIR_SEP..name end; p = function(u, base, name, fd) return base end; n = function(u, base, name, fd) return name end; m = function(u, base, name, fd) return FlagsToMode(fd.dwFileAttributes) end; a = function(u, base, name, fd) return AttributesToStat2(fd) end; z = function(u, base, name, fd) return LargeToNumber ( fd.nFileSize[1], fd.nFileSize[2] ) end; t = function(u, base, name, fd) return FileTimeToTimeT( fd.ftLastWriteTime[1], fd.ftLastWriteTime[2] ) end; c = function(u, base, name, fd) return FileTimeToTimeT( fd.ftCreationTime[1], fd.ftCreationTime[2] ) end; l = function(u, base, name, fd) return FileTimeToTimeT( fd.ftLastAccessTime[1], fd.ftLastAccessTime[2] ) end; } local function make_attrib(str) local t = {} for i = 1, #str do local ch = str:sub(i,i) local fn = attribs[ ch ] if not fn then return nil, 'unknown file attribute: ' .. ch end table.insert(t, fn) end return function(...) local res = {n = #t} for i, f in ipairs(t) do local ok, err = f(...) if ok == nil then return nil, err end table.insert(res, ok) end return res end end function _M.each_impl(u, option) if not option.file then return nil, 'no file mask present' end local base, mask = splitpath( option.file, u.DIR_SEP ) if mask == '' then mask = u.ANY_MASK end local get_params, err = make_attrib(option.param or 'f') if not get_params then return nil, err end local unpack = unpack or table.unpack local filter = option.filter if option.callback then local callback = option.callback local function cb(base, name, path, fd) local params = assert(get_params(u, base, name, path, fd)) if filter and (not filter(unpack(params, 1, params.n))) then return end return callback(unpack(params, 1, params.n)) end return foreach_impl(u, base, mask, cb, option) else local function cb(base, name, path, fd) local params = assert(get_params(u, base, name, path, fd)) if filter and (not filter(unpack(params, 1, params.n))) then return end coroutine.yield(params) end local co = coroutine.create(function() foreach_impl(u, base, mask, cb, option) end) return function() local status, params = coroutine.resume(co) if status then if params then return unpack(params, 1, params.n) end else error(params, 2) end end end end local create_each = require "path.findfile".load local LOADED = {} local function load(ltype, sub) local M = LOADED[ltype .. "/" .. sub] if M then return M end local IMPL = require("path.win32." .. ltype ..".fs")[sub] M = { CONST = CONST; DIR_SEP = IMPL.DIR_SEP; } for k, v in pairs(_M) do if type(v) ~= "function" then M[k] = v else M[k] = function(...) return v(IMPL, ...) end end end local each_impl = _M.each_impl M.each = create_each(function(...) return each_impl(IMPL, ...) end) LOADED[ltype .. "/" .. sub] = M return M end return { load = load }
mit
miralireza2/gpf
bot/bot.lua
4
7095
package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua' ..';.luarocks/share/lua/5.2/?/init.lua' package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so' require("./bot/utils") VERSION = '0.14.6' -- This function is called when tg receive a msg function on_msg_receive (msg) if not started then return end local receiver = get_receiver(msg) -- vardump(msg) msg = pre_process_service_msg(msg) if msg_valid(msg) then msg = pre_process_msg(msg) if msg then match_plugins(msg) mark_read(receiver, ok_cb, false) end end end function ok_cb(extra, success, result) end function on_binlog_replay_end() started = true postpone (cron_plugins, false, 60*5.0) -- See plugins/isup.lua as an example for cron _config = load_config() -- load plugins plugins = {} load_plugins() end function msg_valid(msg) -- Don't process outgoing messages if msg.out then print('\27[36mNot valid: msg from us\27[39m') return false end -- Before bot was started if msg.date < now then print('\27[36mNot valid: old msg\27[39m') return false end if msg.unread == 0 then print('\27[36mNot valid: readed\27[39m') return false end if not msg.to.id then print('\27[36mNot valid: To id not provided\27[39m') return false end if not msg.from.id then print('\27[36mNot valid: From id not provided\27[39m') return false end if msg.from.id == our_id then print('\27[36mNot valid: Msg from our id\27[39m') return false end if msg.to.type == 'encr_chat' then print('\27[36mNot valid: Encrypted chat\27[39m') return false end if msg.from.id == 777000 then print('\27[36mNot valid: Telegram message\27[39m') return false end return true end -- function pre_process_service_msg(msg) if msg.service then local action = msg.action or {type=""} -- Double ! to discriminate of normal actions msg.text = "!!tgservice " .. action.type -- wipe the data to allow the bot to read service messages if msg.out then msg.out = false end if msg.from.id == our_id then msg.from.id = 0 end end return msg end -- Apply plugin.pre_process function function pre_process_msg(msg) for name,plugin in pairs(plugins) do if plugin.pre_process and msg then print('Preprocess', name) msg = plugin.pre_process(msg) end end return msg end -- Go over enabled plugins patterns. function match_plugins(msg) for name, plugin in pairs(plugins) do match_plugin(plugin, name, msg) end end -- Check if plugin is on _config.disabled_plugin_on_chat table local function is_plugin_disabled_on_chat(plugin_name, receiver) local disabled_chats = _config.disabled_plugin_on_chat -- Table exists and chat has disabled plugins if disabled_chats and disabled_chats[receiver] then -- Checks if plugin is disabled on this chat for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do if disabled_plugin == plugin_name and disabled then if plugins[disabled_plugin].hidden then print('Plugin '..disabled_plugin..' is disabled on this chat') else local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' print(warning) send_msg(receiver, warning, ok_cb, false) end return true end end end return false end function match_plugin(plugin, plugin_name, msg) local receiver = get_receiver(msg) -- Go over patterns. If one matches it's enough. for k, pattern in pairs(plugin.patterns) do local matches = match_pattern(pattern, msg.text) if matches then print("msg matches: ", pattern) if is_plugin_disabled_on_chat(plugin_name, receiver) then return nil end -- Function exists if plugin.run then -- If plugin is for privileged users only if not warns_user_not_allowed(plugin, msg) then local result = plugin.run(msg, matches) if result then send_large_msg(receiver, result) end end end -- One patterns matches return end end end -- DEPRECATED, use send_large_msg(destination, text) function _send_msg(destination, text) send_large_msg(destination, text) end -- Save the content of _config to config.lua function save_config( ) serialize_to_file(_config, './data/config.lua') print ('saved config into ./data/config.lua') end -- Returns the config from config.lua file. -- If file doesn't exist, create it. function load_config( ) local f = io.open('./data/config.lua', "r") -- If config.lua doesn't exist if not f then print ("Created new config file: data/config.lua") create_config() else f:close() end local config = loadfile ("./data/config.lua")() for v,user in pairs(config.sudo_users) do print("Allowed user: " .. user) end return config end -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourselves as privileged user config = { enabled_plugins = { "banhammer", "echo", "get", "google", "groupmanager", "help", "id", "images", "img_google", "location", "media", "plugins", "channels", "set", "stats", "time", "version", "weather", "youtube", "media_handler", "moderation"}, sudo_users = {125489381}, disabled_channels = {}, moderation = {data = 'data/moderation.json'} } serialize_to_file(config, './data/config.lua') print ('saved config into ./data/config.lua') end function on_our_id (id) our_id = id end function on_user_update (user, what) --vardump (user) end function on_chat_update (chat, what) --vardump (chat) end function on_secret_chat_update (schat, what) --vardump (schat) end function on_get_difference_end () end -- Enable plugins in config.json function load_plugins() for k, v in pairs(_config.enabled_plugins) do print("Loading plugin", v) local ok, err = pcall(function() local t = loadfile("plugins/"..v..'.lua')() plugins[v] = t end) if not ok then print('\27[31mError loading plugin '..v..'\27[39m') print('\27[31m'..err..'\27[39m') end end end -- custom add function load_data(filename) local f = io.open(filename) if not f then return {} end local s = f:read('*all') f:close() local data = JSON.decode(s) return data end function save_data(filename, data) local s = JSON.encode(data) local f = io.open(filename, 'w') f:write(s) f:close() end -- Call and postpone execution for cron plugins function cron_plugins() for name, plugin in pairs(plugins) do -- Only plugins with cron function if plugin.cron ~= nil then plugin.cron() end end -- Called again in 5 mins postpone (cron_plugins, false, 5*60.0) end -- Start and load values our_id = 0 now = os.time() math.randomseed(now) started = false
gpl-2.0
KayMD/Illarion-Content
item/id_126_sickle.lua
1
1989
--[[ Illarion Server This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ]] -- harvesting herbs and field crops -- UPDATE items SET itm_script='item.id_126_sickle' WHERE itm_id=126; local common = require("base.common") local farming = require("craft.gathering.farming") local herbgathering = require("craft.gathering.herbgathering") local metal = require("item.general.metal") local skillTransfer = require("base.skillTransfer") local M = {} M.LookAtItem = metal.LookAtItem function M.UseItem(User, SourceItem, ltstate) if skillTransfer.skillTransferInformCookingHerbloreFarming(User) then return end local plant; -- field grops (and seeds) plant = farming.getFarmingItem(User); if plant ~= nil then farming.StartGathering(User, plant, ltstate); return; end -- handle herbs which are harvestable first plant = herbgathering.getHerbItem(User, true); if plant ~= nil then herbgathering.StartGathering(User, plant, ltstate); return; end -- try herbs which wont give a harvest as well plant = herbgathering.getHerbItem(User, false); if plant ~= nil then herbgathering.StartGathering(User, plant, ltstate); return; end common.HighInformNLS( User, "Hier ist nichts, wofür du die Sichel benutzen kannst.", "There is nothing for which you can use the sickle." ); end return M
agpl-3.0
Mutos/NAEV-StarsOfCall
docs/ai/examples/attacked.lua
19
1323
--[[ -- Based on when pilot is hit by something, then will attempt to retaliate --]] -- triggered when pilot is hit by something function attacked ( attacker ) task = ai.taskname() if task ~= "attack" and task ~= "runaway" then -- some taunting taunt( attacker ) -- now pilot fights back ai.pushtask(0, "attack", attacker) elseif task == "attack" then if ai.targetid() ~= attacker then ai.pushtask(0, "attack", attacker) end end end -- taunts function taunt ( target ) num = ai.rnd(0,4) if num == 0 then msg = "You dare attack me!" elseif num == 1 then msg = "You are no match for the Empire!" elseif num == 2 then msg = "The Empire will have your head!" elseif num == 3 then msg = "You'll regret this!" end if msg then ai.comm(attacker, msg) end end -- attacks function attack () target = ai.targetid() -- make sure pilot exists if not ai.exists(target) then ai.poptask() return end dir = ai.face( target ) dist = ai.dist( ai.pos(target) ) second = ai.secondary() if ai.secondary() == "Launcher" then ai.settarget(target) ai.shoot(2) end if dir < 10 and dist > 300 then ai.accel() elseif (dir < 10 or ai.hasturrets()) and dist < 300 then ai.shoot() end end
gpl-3.0
dansen/luacode
bin/debug/lua/util/json.lua
3
18228
----------------------------------------------------------------------------- -- JSON4Lua: JSON encoding / decoding support for the Lua language. -- json Module. -- Author: Craig Mason-Jones -- Homepage: http://json.luaforge.net/ -- Version: 0.9.50 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- -- USAGE: -- This module exposes two functions: -- encode(o) -- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string. -- decode(json_string) -- Returns a Lua object populated with the data encoded in the JSON string json_string. -- -- REQUIREMENTS: -- compat-5.1 if using Lua 5.0 -- -- CHANGELOG -- 0.9.50 Radical performance improvement on decode from Eike Decker. Many thanks! -- 0.9.40 Changed licence to MIT License (MIT) -- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). -- Fixed Lua 5.1 compatibility issues. -- Introduced json.null to have null values in associative arrays. -- encode() performance improvement (more than 50%) through table.concat rather than .. -- Introduced decode ability to ignore /**/ comments in the JSON string. -- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- Imports and dependencies ----------------------------------------------------------------------------- local math = math local string = string local table = table local tostring = tostring local base = _G ----------------------------------------------------------------------------- -- Module declaration ----------------------------------------------------------------------------- module("json") -- Public functions -- Private functions local decode_scanArray local decode_scanComment local decode_scanConstant local decode_scanNumber local decode_scanObject local decode_scanString local decode_scanWhitespace local encodeString local isArray local isEncodable ----------------------------------------------------------------------------- -- PUBLIC FUNCTIONS ----------------------------------------------------------------------------- --- Encodes an arbitrary Lua object / variable. -- @param v The Lua object / variable to be JSON encoded. -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) function encode (v) -- Handle nil values if v==nil then return "null" end local vtype = base.type(v) -- Handle strings if vtype=='string' then return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string end -- Handle booleans if vtype=='number' or vtype=='boolean' then return base.tostring(v) end -- Handle tables if vtype=='table' then local rval = {} -- Consider arrays separately local bArray, maxCount = isArray(v) if bArray then for i = 1,maxCount do table.insert(rval, encode(v[i])) end else -- An object, not an array for i,j in base.pairs(v) do if isEncodable(i) and isEncodable(j) then table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j)) end end end if bArray then return '[' .. table.concat(rval,',') ..']' else return '{' .. table.concat(rval,',') .. '}' end end -- Handle null values if vtype=='function' and v==null then return 'null' end base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v)) end --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. -- @param s The string to scan. -- @return Lua objectthat was scanned, as a Lua table / string / number / boolean or nil. function decode(s) -- Function is re-defined below after token and other items are created. -- Just defined here for code neatness. return null end --- The null function allows one to specify a null value in an associative array (which is otherwise -- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null } function null() return null -- so json.null() will also return null ;-) end ----------------------------------------------------------------------------- -- Internal, PRIVATE functions. ----------------------------------------------------------------------------- --- Encodes a string to be JSON-compatible. -- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-) -- @param s The string to return as a JSON encoded (i.e. backquoted string) -- @return The string appropriately escaped. local qrep = {["\\"]="\\\\", ['"']='\\"',['\r']='\\r',['\n']='\\n',['\t']='\\t'} function encodeString(s) return tostring(s):gsub('["\\\r\n\t]',qrep) end -- Determines whether the given Lua type is an array or a table / dictionary. -- We consider any table an array if it has indexes 1..n for its n items, and no -- other data in the table. -- I think this method is currently a little 'flaky', but can't think of a good way around it yet... -- @param t The table to evaluate as an array -- @return boolean, number True if the table can be represented as an array, false otherwise. If true, -- the second returned value is the maximum -- number of indexed elements in the array. function isArray(t) -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable -- (with the possible exception of 'n') local maxIndex = 0 for k,v in base.pairs(t) do if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair if (not isEncodable(v)) then return false end -- All array elements must be encodable maxIndex = math.max(maxIndex,k) else if (k=='n') then if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') end -- End of k,v not an indexed pair end -- End of loop across all pairs return true, maxIndex end --- Determines whether the given Lua object / table / variable can be JSON encoded. The only -- types that are JSON encodable are: string, boolean, number, nil, table and json.null. -- In this implementation, all other types are ignored. -- @param o The object to examine. -- @return boolean True if the object should be JSON encoded, false if it should be ignored. function isEncodable(o) local t = base.type(o) return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) end -- Radical performance improvement for decode from Eike Decker! do local type = base.type local error = base.print--base.error local assert = base.assert local print = base.print local tonumber = base.tonumber -- initialize some values to be used in decoding function -- initializes a table to contain a byte=>table mapping -- the table contains tokens (byte values) as keys and maps them on other -- token tables (mostly, the boolean value 'true' is used to indicate termination -- of a token sequence) -- the token table's purpose is, that it allows scanning a sequence of bytes -- until something interesting has been found (e.g. a token that is not expected) -- name is a descriptor for the table to be printed in error messages local function init_token_table (tt) local struct = {} local value function struct:link(other_tt) value = other_tt return struct end function struct:to(chars) for i=1,#chars do tt[chars:byte(i)] = value end return struct end return function (name) tt.name = name return struct end end -- keep "named" byte values at hands local c_esc, c_e, c_l, c_r, c_u, c_f, c_a, c_s, c_slash = ("\\elrufas/"):byte(1,9) -- token tables - tt_doublequote_string = strDoubleQuot, tt_singlequote_string = strSingleQuot local tt_object_key, tt_object_colon, tt_object_value, tt_doublequote_string, tt_singlequote_string, tt_array_value, tt_array_seperator, tt_numeric, tt_boolean, tt_null, tt_comment_start, tt_comment_middle, tt_ignore --< tt_ignore is special - marked tokens will be tt_ignored = {},{},{},{},{},{},{},{},{},{},{},{},{} -- strings to be used in certain token tables local strchars = "" -- all valid string characters (all except newlines) local allchars = "" -- all characters that are valid in comments --local escapechar = {} for i=0,0xff do local c = string.char(i) if c~="\n" and c~="\r" then strchars = strchars .. c end allchars = allchars .. c --escapechar[i] = "\\" .. string.char(i) end --[[ charstounescape = "\"\'\\bfnrt/"; unescapechars = "\"'\\\b\f\n\r\t\/"; for i=1,#charstounescape do escapechar[ charstounescape:byte(i) ] = unescapechars:sub(i,i) end ]]-- -- obj key reader, expects the end of the object or a quoted string as key init_token_table (tt_object_key) "object (' or \" or } or , expected)" :link(tt_singlequote_string) :to "'" :link(tt_doublequote_string) :to '"' :link(true) :to "}" :link(tt_object_key) :to "," :link(tt_comment_start) :to "/" :link(tt_ignore) :to " \t\r\n" -- after the key, a colon is expected (or comment) init_token_table (tt_object_colon) "object (: expected)" :link(tt_object_value) :to ":" :link(tt_comment_start) :to "/" :link(tt_ignore) :to" \t\r\n" -- as values, anything is possible, numbers, arrays, objects, boolean, null, strings init_token_table (tt_object_value) "object ({ or [ or ' or \" or number or boolean or null expected)" :link(tt_object_key) :to "{" :link(tt_array_seperator) :to "[" :link(tt_singlequote_string) :to "'" :link(tt_doublequote_string) :to '"' :link(tt_numeric) :to "0123456789.-" :link(tt_boolean) :to "tf" :link(tt_null) :to "n" :link(tt_comment_start) :to "/" :link(tt_ignore) :to " \t\r\n" -- token tables for reading strings init_token_table (tt_doublequote_string) "double quoted string" :link(tt_ignore) :to (strchars) :link(c_esc) :to "\\" :link(true) :to '"' init_token_table (tt_singlequote_string) "single quoted string" :link(tt_ignore) :to (strchars) :link(c_esc) :to "\\" :link(true) :to "'" -- array reader that expects termination of the array or a comma that indicates the next value init_token_table (tt_array_value) "array (, or ] expected)" :link(tt_array_seperator) :to "," :link(true) :to "]" :link(tt_comment_start) :to "/" :link(tt_ignore) :to " \t\r\n" -- a value, pretty similar to tt_object_value init_token_table (tt_array_seperator) "array ({ or [ or ] or ' or \" or number or boolean or null expected)" :link(tt_object_key) :to "{" :link(tt_array_seperator) :to "[" :link(tt_singlequote_string) :to "'" :link(tt_doublequote_string) :to '"' :link(tt_comment_start) :to "/" :link(tt_numeric) :to "0123456789.-" :link(tt_boolean) :to "tf" :link(tt_null) :to "n" :link(tt_ignore) :to " \t\r\n" :link(tt_array_value) :to "]" -- valid number tokens init_token_table (tt_numeric) "number" :link(tt_ignore) :to "0123456789.-Ee" -- once a comment has been started with /, a * is expected init_token_table (tt_comment_start) "comment start (* expected)" :link(tt_comment_middle) :to "*" -- now everything is allowed, watch out for * though. The next char is then checked manually init_token_table (tt_comment_middle) "comment end" :link(tt_ignore) :to (allchars) :link(true) :to "*" function decode (js_string) local pos = 1 -- position in the string -- read the next byte value local function next_byte () pos = pos + 1 return js_string:byte(pos-1) end -- in case of error, report the location using line numbers local function location () local n = ("\n"):byte() local line,lpos = 1,0 for i=1,pos do if js_string:byte(i) == n then line,lpos = line + 1,1 else lpos = lpos + 1 end end return "Line "..line.." character "..lpos end -- debug func --local function status (str) -- print(str.." ("..s:sub(math.max(1,p-10),p+10)..")") --end -- read the next token, according to the passed token table local function next_token (tok) while pos <= #js_string do local b = js_string:byte(pos) local t = tok[b] if not t then error("Unexpected character at "..location()..": ".. string.char(b).." ("..b..") when reading "..tok.name.."\nContext: \n".. js_string:sub(math.max(1,pos-30),pos+30).."\n"..(" "):rep(pos+math.min(-1,30-pos)).."^") return t end pos = pos + 1 if t~=tt_ignore then return t end end error("unexpected termination of JSON while looking for "..tok.name) end -- read a string, double and single quoted ones local function read_string (tok) local start = pos --local returnString = {} repeat local t = next_token(tok) if t == c_esc then --table.insert(returnString, js_string:sub(start, pos-2)) --table.insert(returnString, escapechar[ js_string:byte(pos) ]) pos = pos + 1 --start = pos end -- jump over escaped chars, no matter what until t == true return (base.loadstring("return " .. js_string:sub(start-1, pos-1) ) ()) -- We consider the situation where no escaped chars were encountered separately, -- and use the fastest possible return in this case. --if 0 == #returnString then -- return js_string:sub(start,pos-2) --else -- table.insert(returnString, js_string:sub(start,pos-2)) -- return table.concat(returnString,""); --end --return js_string:sub(start,pos-2) end local function read_num () local start = pos while pos <= #js_string do local b = js_string:byte(pos) if not tt_numeric[b] then break end pos = pos + 1 end return tonumber(js_string:sub(start-1,pos-1)) end -- read_bool and read_null are both making an assumption that I have not tested: -- I would expect that the string extraction is more expensive than actually -- making manual comparision of the byte values local function read_bool () pos = pos + 3 local a,b,c,d = js_string:byte(pos-3,pos) if a == c_r and b == c_u and c == c_e then return true end pos = pos + 1 if a ~= c_a or b ~= c_l or c ~= c_s or d ~= c_e then error("Invalid boolean: "..js_string:sub(math.max(1,pos-5),pos+5)) end return false end -- same as read_bool: only last local function read_null () pos = pos + 3 local u,l1,l2 = js_string:byte(pos-3,pos-1) if u == c_u and l1 == c_l and l2 == c_l then return nil end error("Invalid value (expected null):"..js_string:sub(pos-4,pos-1).. " ("..js_string:byte(pos-1).."="..js_string:sub(pos-1,pos-1).." / "..c_l..")") end local read_object_value,read_object_key,read_array,read_value,read_comment -- read a value depending on what token was returned, might require info what was used (in case of comments) function read_value (t,fromt) if t == tt_object_key then return read_object_key({}) end if t == tt_array_seperator then return read_array({}) end if t == tt_singlequote_string or t == tt_doublequote_string then return read_string(t) end if t == tt_numeric then return read_num() end if t == tt_boolean then return read_bool() end if t == tt_null then return read_null() end if t == tt_comment_start then return read_value(read_comment(fromt)) end error("unexpected termination - "..js_string:sub(math.max(1,pos-10),pos+10)) end -- read comments until something noncomment like surfaces, using the token reader which was -- used when stumbling over this comment function read_comment (fromt) while true do next_token(tt_comment_start) while true do local t = next_token(tt_comment_middle) if next_byte() == c_slash then local t = next_token(fromt) if t~= tt_comment_start then return t end break end end end end -- read arrays, empty array expected as o arg function read_array (o,i) --if not i then status "arr open" end i = i or 1 -- loop until ... while true do local array_token = next_token(tt_array_seperator) if t == tt_array_value then -- ... we found a terminator token ']' return o end o[i] = read_value(array_token, tt_array_seperator) local t = next_token(tt_array_value) if t == tt_comment_start then t = read_comment(tt_array_value) end if t == true then -- ... we found a terminator token --status "arr close" return o end i = i + 1 end end -- object value reading function read_object_value (o) local t = next_token(tt_object_value) if not t then return t end return read_value(t,tt_object_value) end -- object key reading, might also terminate the object function read_object_key (o) while true do local t = next_token(tt_object_key) if t == tt_comment_start then t = read_comment(tt_object_key) end if t == true then return o end if t == tt_object_key then return read_object_key(o) end local k = read_string(t) if next_token(tt_object_colon) == tt_comment_start then t = read_comment(tt_object_colon) end local v = read_object_value(o) o[k] = v end end -- now let's read data from our string and pretend it's an object value local r = read_object_value() if pos<=#js_string then -- not sure about what to do with dangling characters --error("Dangling characters in JSON code ("..location()..")") end return r end end
mit
cecile/Cecile_QuickLaunch
src/Cecile_QuickLaunch/libs/LibStub/LibStub.lua
184
1367
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info -- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! local LibStub = _G[LIBSTUB_MAJOR] if not LibStub or LibStub.minor < LIBSTUB_MINOR then LibStub = LibStub or {libs = {}, minors = {} } _G[LIBSTUB_MAJOR] = LibStub LibStub.minor = LIBSTUB_MINOR function LibStub:NewLibrary(major, minor) assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") local oldminor = self.minors[major] if oldminor and oldminor >= minor then return nil end self.minors[major], self.libs[major] = minor, self.libs[major] or {} return self.libs[major], oldminor end function LibStub:GetLibrary(major, silent) if not self.libs[major] and not silent then error(("Cannot find a library instance of %q."):format(tostring(major)), 2) end return self.libs[major], self.minors[major] end function LibStub:IterateLibraries() return pairs(self.libs) end setmetatable(LibStub, { __call = LibStub.GetLibrary }) end
artistic-2.0
gajop/Zero-K
scripts/cruisemissile.lua
7
1222
include "constants.lua" local base = piece 'base' function script.AimWeapon1(heading, pitch) return true end local function RemoveMissile() Spring.SetUnitNoSelect(unitID, true) Spring.SetUnitNoDraw(unitID, true) Spring.SetUnitNoMinimap(unitID, true) Spring.SetUnitHealth(unitID, {paralyze=99999999}) Spring.SetUnitCloak(unitID, 4) Spring.SetUnitStealth(unitID, true) Spring.SetUnitBlocking(unitID,false,false,false) Sleep(2000) -- keep alive for stats Spring.SetUnitPosition(unitID,-9001, -9001) -- Note that missiles intentionally remove their command 2s after firing -- instead of immediately. This is to give some command feedback (that the -- command actually was placed) and to show allies where the launch occurred. Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0) GG.DestroyMissile(unitID, unitDefID) Sleep(15000) Spring.DestroyUnit(unitID, false, true) end function script.Shot() StartThread(RemoveMissile) end function script.AimFromWeapon() return base end function script.QueryWeapon() return base end function script.Create() Turn(base, x_axis, math.rad(-90)) Move(base, y_axis, 40) end function script.Killed(recentDamage, maxHealth) Explode(base, sfxNone) return 1 end
gpl-2.0
pixeltailgames/gm-mediaplayer
lua/mediaplayer/players/base/cl_fullscreen.lua
1
2312
local pcall = pcall local Color = Color local RealTime = RealTime local ScrW = ScrW local ScrH = ScrH local ValidPanel = ValidPanel local Vector = Vector local cam = cam local draw = draw local math = math local string = string local surface = surface local FullscreenCvar = MediaPlayer.Cvars.Fullscreen --[[--------------------------------------------------------- Convar callback -----------------------------------------------------------]] local function OnFullscreenConVarChanged( name, old, new ) new = (new == "1.00") old = (old == "1.00") local media for _, mp in pairs(MediaPlayer.List) do mp._LastMediaUpdate = RealTime() media = mp:CurrentMedia() if IsValid(media) and ValidPanel(media.Browser) then MediaPlayer.SetBrowserSize( media.Browser ) end end MediaPlayer.SetBrowserSize( MediaPlayer.GetIdlescreen() ) hook.Run( "MediaPlayerFullscreenToggled", new, old ) end cvars.AddChangeCallback( FullscreenCvar:GetName(), OnFullscreenConVarChanged ) --[[--------------------------------------------------------- Client controls for toggling fullscreen -----------------------------------------------------------]] inputhook.AddKeyPress( KEY_F11, "Toggle MediaPlayer Fullscreen", function() local isFullscreen = FullscreenCvar:GetBool() local numMp = #MediaPlayer.GetAll() -- only toggle if there's an active media player or we're in fullscreen mode if numMp == 0 and not isFullscreen then return end local value = isFullscreen and 0 or 1 RunConsoleCommand( "mediaplayer_fullscreen", value ) end ) --[[--------------------------------------------------------- Draw functions -----------------------------------------------------------]] function MEDIAPLAYER:DrawFullscreen() -- Don't draw if we're not fullscreen if not FullscreenCvar:GetBool() then return end local w, h = ScrW(), ScrH() local media = self:CurrentMedia() if IsValid(media) then -- Custom media draw function if media.Draw then media:Draw( w, h ) end -- TODO: else draw 'not yet implemented' screen? -- Draw media info local succ, err = pcall( self.DrawMediaInfo, self, media, w, h ) if not succ then print( err ) end else local browser = MediaPlayer.GetIdlescreen() if ValidPanel(browser) then self:DrawHTML( browser, w, h ) end end end
mit
Sojerbot/javan
plugins/music.lua
1
2312
--[[ # # Music Downloader # # @Dragon_Born # @GPMod # # ]] local function musiclink(msg, musicid) local value = redis:hget('music:'..msg.to.id, musicid) if not value then return else value = value..'\n\n@GPMod' return value end end ------------------ Seconds To Minutes alg ------------------ function sectomin (Sec) if (tonumber(Sec) == nil) or (tonumber(Sec) == 0) then return "00:00" else Seconds = math.floor(tonumber(Sec)) if Seconds < 1 then Seconds = 1 end Minutes = math.floor(Seconds / 60) Seconds = math.floor(Seconds - (Minutes * 60)) if Seconds < 10 then Seconds = "0"..Seconds end if Minutes < 10 then Minutes = "0"..Minutes end return Minutes..':'..Seconds end end function run(msg, matches) if string.match(msg.text, '[\216-\219][\128-\191]') then return send_large_msg(get_receiver(msg), 'فارسی پشتیبانی نمیشود\nاز متن فینگلیش استفاده کنید. ') end if matches[1]:lower() == "dl" then local value = redis:hget('music:'..msg.to.id, matches[2]) if not value then return 'آهنگ مورد نظر پیدا نشد.' else value = value..'\n\n' return value end return end local url = http.request("http://api.gpmod.ir/music.search/?q="..URL.escape(matches[2]).."&count=30&sort=2") --[[ -- Sort order: -- 1 — by duration -- 2 — by popularity -- 0 — by date added --- -- max counts = 300 ]] local jdat = json:decode(url) local text , time , num = '' local hash = 'music:'..msg.to.id redis:del(hash) if #jdat.response < 2 then return "No result found." end for i = 2, #jdat.response do if 900 > jdat.response[i].duration then num = i - 1 time = sectomin(jdat.response[i].duration) text = text..num..'- Artist: '.. jdat.response[i].artist .. ' | '..time..'\nTitle: '..jdat.response[i].title..'\n\n' redis:hset(hash, num, 'Artist: '.. jdat.response[i].artist .. '\nTitle: '..jdat.response[i].title..' | '..time..'\n\n'.."GPMod.ir/dl.php?q="..jdat.response[i].owner_id.."_"..jdat.response[i].aid) end end text = text..'برای دریافت لینک دانلود از دستور زیر استفاده کنید\n/dl <number>\n(example): /dl 1' return text end return { patterns = { "^[/!]([Mm][Uu][Ss][Ii][Cc]) (.*)$", "^[/!]([dD][Ll]) (.*)$" }, run = run }
gpl-2.0
gajop/Zero-K
LuaRules/Configs/tactical_ai_defs.lua
2
23803
-------------------------------------------------------------------------------- -------------------------------------------------------------------------------- local function Union(t1, t2) local ret = {} for i, v in pairs(t1) do ret[i] = v end for i, v in pairs(t2) do ret[i] = v end return ret end local function NameToDefID(nameTable) local defTable = {} for _,unitName in pairs(nameTable) do local ud = UnitDefNames[unitName] if ud then defTable[ud.id] = true end end return defTable end local function SetMinus(set, exclusion) local copy = {} for i,v in pairs(set) do copy[i] = v end for _, unitName in ipairs(exclusion) do local ud = UnitDefNames[unitName] if ud and ud.id then copy[ud.id] = nil end end return copy end -- swarm arrays -- these are not strictly required they just help with inputting the units local longRangeSwarmieeArray = NameToDefID({ "cormart", "firewalker", "armsptk", "corstorm", "shiparty", "armham", }) local medRangeSwarmieeArray = NameToDefID({ "armrock", "amphfloater", "chickens", }) local lowRangeSwarmieeArray = NameToDefID({ "corthud", "spiderassault", "corraid", "armzeus", "logkoda", "hoverassault", "correap", "corgol", "armcrabe", "armmanni", "chickenr", "chickenblobber", "armsnipe", -- only worth swarming sniper at low range, too accurate otherwise. }) medRangeSwarmieeArray = Union(medRangeSwarmieeArray,longRangeSwarmieeArray) lowRangeSwarmieeArray = Union(lowRangeSwarmieeArray,medRangeSwarmieeArray) -- skirm arrays -- these are not strictly required they just help with inputting the units local veryShortRangeSkirmieeArray = NameToDefID({ "corclog", "corcan", "spherepole", "armtick", "puppy", "corroach", "chicken", "chickena", "chicken_tiamat", "chicken_dragon", "hoverdepthcharge", "corgator", "armflea", "armpw", "corfav", }) local shortRangeSkirmieeArray = NameToDefID({ "corpyro", "logkoda", "amphraider3", "corsumo", "corsktl", "corak", }) local riotRangeSkirmieeArray = NameToDefID({ "panther", "corsh", "armwar", "hoverscout", "shipscout", "shipraider", "subraider", "amphriot", "armcomdgun", "dante", "armjeth", "corcrash", "armaak", "hoveraa", "spideraa", "amphaa", "shipaa", "armrectr", "cornecro", "corned", "corch", "coracv", "arm_spider", "corfast", "amphcon", "shipcon", "spherecloaker", "core_spectre", }) local lowMedRangeSkirmieeArray = NameToDefID({ "armcom", "armadvcom", "hoverassault", "arm_venom", "cormak", "corthud", "corraid", }) local medRangeSkirmieeArray = NameToDefID({ "corcom", "coradvcom", "commsupport", "commadvsupport", "spiderriot", "armzeus", "amphraider2", "spiderassault", "corlevlr", "hoverriot", "shieldfelon", "correap", "corgol", "tawf114", -- banisher }) for name, data in pairs(UnitDefNames) do -- add all comms to mid range skirm if data.customParams.commtype then medRangeSkirmieeArray[data.id] = true end end local longRangeSkirmieeArray = NameToDefID({ "armrock", "slowmort", "amphfloater", "nsclash", -- hover janus "capturecar", "chickenc", "armbanth", "gorg", "corllt", "armdeva", "armartic", }) local artyRangeSkirmieeArray = NameToDefID({ "shipskirm", "armsptk", "corstorm", "cormist", "amphassault", "chicken_sporeshooter", "corrl", "corhlt", "armpb", "cordoom", "armorco", "amphartillery", }) local slasherSkirmieeArray = NameToDefID({ "corsumo", "dante", "armwar", "hoverassault", "cormak", "corthud", "spiderriot", "armzeus", "spiderassault", "corraid", "corlevlr", "hoverriot", "shieldfelon", "correap", "armrock", }) local sniperSkirmieeArray = {} for name,data in pairs(UnitDefNames) do if data.speed > 0 and not data.canfly then sniperSkirmieeArray[data.id] = true end end shortRangeSkirmieeArray = Union(shortRangeSkirmieeArray,veryShortRangeSkirmieeArray) riotRangeSkirmieeArray = Union(riotRangeSkirmieeArray,shortRangeSkirmieeArray) lowMedRangeSkirmieeArray = Union(lowMedRangeSkirmieeArray, riotRangeSkirmieeArray) medRangeSkirmieeArray = Union(medRangeSkirmieeArray, lowMedRangeSkirmieeArray) longRangeSkirmieeArray = Union(longRangeSkirmieeArray,medRangeSkirmieeArray) artyRangeSkirmieeArray = Union(artyRangeSkirmieeArray,longRangeSkirmieeArray) -- Stuff that mobile AA skirms local skirmableAir = NameToDefID({ "blastwing", "bladew", "armkam", "gunshipsupport", "armbrawl", "blackdawn", "corbtrans", "corcrw", }) -- Brawler, for AA to swarm. local brawler = NameToDefID({ "armbrawl", }) -- Things that are fled by some things local fleeables = NameToDefID({ "corllt", "armdeva", "armartic", "corgrav", "armcom", "armadvcom", "corcom", "coradvcom", "armwar", "armzeus", "arm_venom", "spiderriot", "cormak", "corlevlr", "capturecar", "hoverriot", -- mumbo "shieldfelon", "corsumo", }) local armedLand = {} for name,data in pairs(UnitDefNames) do if data.canAttack and (not data.canfly) and data.weapons[1] and data.weapons[1].onlyTargets.land then armedLand[data.id] = true end end -- waterline(defaults to 0): Water level at which the unit switches between land and sea behaviour -- sea: table of behaviour for sea. Note that these tables are optional. -- land: table of behaviour for land -- weaponNum(defaults to 1): Weapon to use when skirming -- searchRange(defaults to 800): max range of GetNearestEnemy for the unit. -- defaultAIState (defaults in config): (1 or 0) state of AI when unit is initialised --*** skirms(defaults to empty): the table of units that this unit will attempt to keep at max range -- skirmEverything (defaults to false): Skirms everything (does not skirm radar with this enabled only) -- skirmLeeway (defaults to 0): (Weapon range - skirmLeeway) = distance that the unit will try to keep from units while skirming -- stoppingDistance (defaults to 0): (skirmLeeway - stoppingDistance) = max distance from target unit that move commands can be given while skirming -- skirmRadar (defaults to false): Skirms radar dots -- skirmOnlyNearEnemyRange (defaults to false): If true, skirms only when the enemy unit is withing enemyRange + skirmOnlyNearEnemyRange -- skirmOrderDis (defaults in config): max distance the move order is from the unit when skirming -- skirmKeepOrder (defaults to false): If true the unit does not clear its move order when too far away from the unit it is skirming. -- velocityPrediction (defaults in config): number of frames of enemy velocity prediction for skirming and fleeing --*** swarms(defaults to empty): the table of units that this unit will jink towards and strafe -- maxSwarmLeeway (defaults to Weapon range): (Weapon range - maxSwarmLeeway) = Max range that the unit will begin strafing targets while swarming -- minSwarmLeeway (defaults to Weapon range): (Weapon range - minSwarmLeeway) = Range that the unit will attempt to move further away from the target while swarming -- jinkTangentLength (default in config): component of jink vector tangent to direction to enemy -- jinkParallelLength (default in config): component of jink vector parallel to direction to enemy -- circleStrafe (defaults to false): when set to true the unit will run all around the target unit, false will cause the unit to jink back and forth -- minCircleStrafeDistance (default in config): (weapon range - minCircleStrafeDistance) = distance at which the circle strafer will attempt to move away from target -- strafeOrderLength (default in config): length of move order while strafing -- swarmLeeway (defaults to 50): adds to enemy range when swarming -- swarmEnemyDefaultRange (defaults to 800): range of the enemy used if it cannot be seen. -- alwaysJinkFight (defaults to false): If enabled the unit with jink whenever it has a fight command -- localJinkOrder (defaults in config): Causes move commands to be given near the unit, otherwise given next to opponent --*** flees(defaults to empty): the table of units that this unit will flee like the coward it is!!! -- fleeCombat (defaults to false): if true will flee everything without catergory UNARMED -- fleeLeeway (defaults to 100): adds to enemy range when fleeing -- fleeDistance (defaults to 100): unit will flee to enemy range + fleeDistance away from enemy -- fleeRadar (defaults to false): does the unit flee radar dots? -- minFleeRange (defaults to 0): minumun range at which the unit will flee, will flee at higher range if the attacking unit outranges it -- fleeOrderDis (defaults to 120): max distance the move order is from the unit when fleeing --- Array loaded into gadget local behaviourDefaults = { defaultState = 1, defaultJinkTangentLength = 80, defaultJinkParallelLength = 200, defaultStrafeOrderLength = 100, defaultMinCircleStrafeDistance = 40, defaultLocalJinkOrder = true, defaultSkirmOrderDis = 120, defaultVelocityPrediction = 30, } local behaviourConfig = { -- swarmers ["armtick"] = { skirms = {}, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, jinkTangentLength = 100, minCircleStrafeDistance = 0, minSwarmLeeway = 100, swarmLeeway = 30, alwaysJinkFight = true, }, ["corroach"] = { skirms = {}, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, jinkTangentLength = 100, minCircleStrafeDistance = 0, minSwarmLeeway = 100, swarmLeeway = 30, alwaysJinkFight = true, }, ["puppy"] = { skirms = {}, swarms = lowRangeSwarmieeArray, flees = {}, localJinkOrder = false, circleStrafe = true, minCircleStrafeDistance = 170, maxSwarmLeeway = 170, jinkTangentLength = 100, minSwarmLeeway = 100, swarmLeeway = 200, }, ["armpw"] = { skirms = veryShortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 35, swarmLeeway = 50, skirmLeeway = 10, jinkTangentLength = 140, stoppingDistance = 10, }, ["armflea"] = { skirms = veryShortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = fleeables, circleStrafe = true, maxSwarmLeeway = 5, swarmLeeway = 30, stoppingDistance = 0, strafeOrderLength = 100, minCircleStrafeDistance = 20, fleeLeeway = 150, fleeDistance = 150, }, ["corfav"] = { -- weasel skirms = veryShortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = fleeables, circleStrafe = true, strafeOrderLength = 180, maxSwarmLeeway = 40, swarmLeeway = 40, stoppingDistance = 15, minCircleStrafeDistance = 50, fleeLeeway = 100, fleeDistance = 150, }, -- longer ranged swarmers ["corak"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 35, swarmLeeway = 30, jinkTangentLength = 140, stoppingDistance = 10, minCircleStrafeDistance = 10, velocityPrediction = 30, }, ["amphraider3"] = { waterline = -5, land = { weaponNum = 1, skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 35, swarmLeeway = 30, jinkTangentLength = 140, stoppingDistance = 25, minCircleStrafeDistance = 10, velocityPrediction = 30, }, sea = { weaponNum = 2, skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 35, swarmLeeway = 30, jinkTangentLength = 140, stoppingDistance = 25, minCircleStrafeDistance = 10, velocityPrediction = 30, }, }, ["corgator"] = { skirms = {}, swarms = lowRangeSwarmieeArray, flees = {}, localJinkOrder = false, jinkTangentLength = 50, circleStrafe = true, strafeOrderLength = 100, minCircleStrafeDistance = 260, skirmLeeway = 60, maxSwarmLeeway = 0, minSwarmLeeway = 100, swarmLeeway = 300, stoppingDistance = 8, skirmOrderDis = 150, }, ["hoverscout"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, strafeOrderLength = 180, maxSwarmLeeway = 40, swarmLeeway = 40, stoppingDistance = 8, skirmOrderDis = 150, }, ["corsh"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, strafeOrderLength = 180, maxSwarmLeeway = 40, swarmLeeway = 40, stoppingDistance = 8, skirmOrderDis = 150, }, ["corpyro"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 100, minSwarmLeeway = 200, swarmLeeway = 30, stoppingDistance = 8, velocityPrediction = 20 }, ["logkoda"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, swarmLeeway = 30, stoppingDistance = 8, skirmOrderDis = 150, }, ["panther"] = { skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, strafeOrderLength = 180, maxSwarmLeeway = 40, swarmLeeway = 50, stoppingDistance = 15, skirmOrderDis = 150, }, ["shipscout"] = { -- scout boat skirms = shortRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, swarmLeeway = 30, stoppingDistance = 8 }, ["amphraider2"] = { skirms = riotRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, skirmLeeway = 30, minCircleStrafeDistance = 10, velocityPrediction = 20 }, -- riots ["armwar"] = { skirms = riotRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 0, skirmLeeway = 0, velocityPrediction = 20 }, ["spiderriot"] = { skirms = lowMedRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 0, skirmLeeway = 0, velocityPrediction = 20 }, ["arm_venom"] = { skirms = riotRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, skirmLeeway = 30, minCircleStrafeDistance = 10, velocityPrediction = 20 }, ["cormak"] = { skirms = riotRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 0, skirmLeeway = 50, velocityPrediction = 20 }, ["corlevlr"] = { skirms = lowMedRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 0, skirmLeeway = -30, stoppingDistance = 5 }, ["shieldfelon"] = { skirms = lowMedRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 0, skirmLeeway = -30, stoppingDistance = 5 }, ["hoverriot"] = { skirms = lowMedRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 0, skirmLeeway = -30, stoppingDistance = 5 }, ["tawf114"] = { skirms = lowMedRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 0, skirmLeeway = -30, stoppingDistance = 10 }, ["amphriot"] = { waterline = -5, land = { weaponNum = 1, skirms = riotRangeSkirmieeArray, swarms = {}, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, skirmLeeway = 30, minCircleStrafeDistance = 10, }, sea = { weaponNum = 2, skirms = riotRangeSkirmieeArray, swarms = {}, flees = {}, circleStrafe = true, maxSwarmLeeway = 40, skirmLeeway = 30, minCircleStrafeDistance = 10, }, }, ["amphartillery"] = { waterline = -5, land = { weaponNum = 1, skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 40, }, sea = { weaponNum = 2, skirms = medRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 40, }, }, --assaults ["armzeus"] = { skirms = lowMedRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 90, skirmLeeway = 20, }, ["corthud"] = { skirms = riotRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 50, minSwarmLeeway = 120, skirmLeeway = 40, }, ["spiderassault"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 50, minSwarmLeeway = 120, skirmLeeway = 40, }, ["corraid"] = { skirms = riotRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 50, minSwarmLeeway = 120, skirmLeeway = 40, }, ["dante"] = { skirms = medRangeSkirmieeArray, swarms = {}, flees = {}, skirmLeeway = 40, }, ["shipraider"] = { skirms = riotRangeSkirmieeArray, swarms = lowRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 90, skirmLeeway = 60, }, -- med range skirms ["armrock"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 10, }, ["slowmort"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 20, }, ["amphfloater"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 10, }, ["nsaclash"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 30, skirmOrderDis = 200, velocityPrediction = 90, }, ["shiptorp"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 0, stoppingDistance = -40, skirmOrderDis = 250, velocityPrediction = 40, }, ["gunshipsupport"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, }, ["corcrw"] = { skirms = medRangeSkirmieeArray, swarms = medRangeSwarmieeArray, flees = {}, skirmLeeway = 30, }, -- long range skirms ["jumpblackhole"] = { skirms = longRangeSkirmieeArray, swarms = longRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 20, }, ["corstorm"] = { skirms = longRangeSkirmieeArray, swarms = longRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 10, }, ["armsptk"] = { skirms = longRangeSkirmieeArray, swarms = longRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 10, }, ["corcrw"] = { skirms = longRangeSkirmieeArray, swarms = {}, flees = {}, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 20, }, ["capturecar"] = { skirms = longRangeSkirmieeArray, swarms = longRangeSwarmieeArray, flees = {}, maxSwarmLeeway = 30, minSwarmLeeway = 130, skirmLeeway = 30, skirmOrderDis = 200, velocityPrediction = 60, }, -- weird stuff ["cormist"] = { defaultAIState = 0, skirms = slasherSkirmieeArray, swarms = {}, flees = {}, skirmLeeway = -400, skirmOrderDis = 700, skirmKeepOrder = true, velocityPrediction = 10, skirmOnlyNearEnemyRange = 80 }, -- arty range skirms ["armbanth"] = { skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmLeeway = 60, }, ["armsnipe"] = { skirms = sniperSkirmieeArray, swarms = {}, flees = {}, skirmLeeway = 300, }, ["corgarp"] = { skirms = SetMinus(artyRangeSkirmieeArray, {"corhlt"}), swarms = {}, flees = {}, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 10, }, ["armham"] = { skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 40, }, --["subarty"] = { -- skirms = artyRangeSkirmieeArray, -- swarms = {}, -- flees = {}, -- skirmRadar = true, -- maxSwarmLeeway = 10, -- minSwarmLeeway = 130, -- skirmLeeway = 80, -- skirmOrderDis = 250, -- velocityPrediction = 40, --}, ["shiparty"] = { skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 40, }, ["firewalker"] = { skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 20, }, ["shieldarty"] = { skirms = Union(artyRangeSkirmieeArray, skirmableAir), swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 150, }, ["armmanni"] = { skirms = artyRangeSkirmieeArray, swarms = {}, flees = {}, skirmRadar = true, maxSwarmLeeway = 10, minSwarmLeeway = 130, skirmLeeway = 40, }, -- cowardly support units --[[ ["example"] = { skirms = {}, swarms = {}, flees = {}, fleeCombat = true, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, }, --]] -- support ["spherecloaker"] = { skirms = {}, swarms = {}, flees = armedLand, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 400, }, ["core_spectre"] = { skirms = {}, swarms = {}, flees = armedLand, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 450, }, -- mobile AA ["armjeth"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, }, ["corcrash"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 500, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, }, ["vehaa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 100, strafeOrderLength = 180, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, }, ["armaak"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 300, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, }, ["hoveraa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 100, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, skirmOrderDis = 200, }, ["spideraa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 300, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, }, ["corsent"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 100, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, skirmOrderDis = 200, }, ["amphaa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, skirmOrderDis = 200, }, ["shipaa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 100, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, skirmOrderDis = 200, }, ["gunshipaa"] = { skirms = skirmableAir, swarms = brawler, flees = armedLand, minSwarmLeeway = 100, fleeLeeway = 100, fleeDistance = 100, minFleeRange = 500, skirmLeeway = 50, skirmOrderDis = 200, }, } return behaviourConfig, behaviourDefaults -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
gpl-2.0
Sweet-kid/Algorithm-Implementations
Lempel_Ziv_Welch/Lua/Yonaba/lzw_test.lua
26
1030
-- Tests for lzw.lua local lzw = require 'lzw' local total, pass = 0, 0 local function dec(str, len) return #str < len and str .. (('.'):rep(len-#str)) or str:sub(1,len) end local function run(message, f) total = total + 1 local ok, err = pcall(f) if ok then pass = pass + 1 end local status = ok and 'PASSED' or 'FAILED' print(('%02d. %68s: %s'):format(total, dec(message,68), status)) end local function same(t1, t2) if #t1 ~= #t2 then return false end for k,v in ipairs(t1) do if v ~= t2[k] then return false end end return true end run('Encoding string test', function() assert(same(lzw.encode('TOBEORNOTTOBEORTOBEORNOT'), {84, 79, 66, 69, 79, 82, 78, 79, 84, 256, 258, 260, 265, 259, 261, 263})) end) run('Decoding string test', function() assert(lzw.decode(lzw.encode('TOBEORNOTTOBEORTOBEORNOT')) == 'TOBEORNOTTOBEORTOBEORNOT') end) print(('-'):rep(80)) print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%') :format(total, pass, total-pass, (pass*100/total)))
mit
jayman39tx/naev
dat/missions/empire/longdistanceshipping/emp_longdistancecargo2.lua
2
3098
--[[ Second diplomatic mission to Dvaered space that opens up the Empire long-distance cargo missions. Author: micahmumper ]]-- include "dat/scripts/numstring.lua" include "dat/scripts/jumpdist.lua" bar_desc = _("Lieutenant Czesc from the Empire Armada Shipping Division is sitting at the bar.") misn_title = _("Dvaered Long Distance Recruitment") misn_reward = _("50000 credits") misn_desc = _("Deliver a shipping diplomat for the Empire to Praxis in the Ogat system.") title = {} title[1] = _("Spaceport Bar") title[2] = _("Dvaered Long Distance Recruitment") title[3] = _("Mission Accomplished") text = {} text[1] = _([[Lieutenant Czesc waves you over when he notices you enter the bar. "I knew we would run into each other soon enough. Great job delivering that bureaucrat. We should be up and running in Soromid space in no time!" He presses a button on his wrist computer. "We're hoping to expand to Dvaered territory next. Can I count on your help?"]]) text[2] = _([["Great!" says Lieutenant Czesc. "I'll send a message to the bureaucrat to meet you at the hanger. The Dvaered are, of course, allies of the Empire. Still, they offend easily, so try not to talk too much. Your mission is to drop the bureaucrat off on Praxis in the Ogat system. He will take it from there and report back to me when the shipping contract has been confirmed. Afterwards, keep an eye out for me in Empire space and we can continue the operation."]]) text[3] = _([[You drop the bureaucrat off on Praxis, and he hands you a credit chip. You remember Lieutenant Czesc told you to look for him on Empire controlled planets after you finish.]]) function create () -- Note: this mission does not make any system claims. -- Get the planet and system at which we currently are. startworld, startworld_sys = planet.cur() -- Set our target system and planet. targetworld_sys = system.get("Ogat") targetworld = planet.get("Praxis") misn.setNPC( _("Lieutenant"), "empire/unique/czesc" ) misn.setDesc( bar_desc ) end function accept () -- Set marker to a system, visible in any mission computer and the onboard computer. misn.markerAdd( targetworld_sys, "low") ---Intro Text if not tk.yesno( title[1], text[1] ) then misn.finish() end -- Flavour text and mini-briefing tk.msg( title[2], text[2] ) ---Accept the mission misn.accept() -- Description is visible in OSD and the onboard computer, it shouldn't be too long either. reward = 50000 misn.setTitle(misn_title) misn.setReward(misn_reward) misn.setDesc( string.format( misn_desc, targetworld:name(), targetworld_sys:name() ) ) misn.osdCreate(title[2], {misn_desc}) -- Set up the goal hook.land("land") person = misn.cargoAdd( "Person" , 0 ) end function land() if planet.cur() == targetworld then misn.cargoRm( person ) player.pay( reward ) -- More flavour text tk.msg( title[3], text[3] ) faction.modPlayerSingle( "Empire",3 ); misn.finish(true) end end function abort() misn.finish(false) end
gpl-3.0