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
EliHar/Pattern_recognition
torch1/extra/nn/Cosine.lua
19
5784
local Cosine, parent = torch.class('nn.Cosine', 'nn.Module') function Cosine:__init(inputSize,outputSize) parent.__init(self) self.weight = torch.Tensor(outputSize,inputSize) self.gradWeight = torch.Tensor(outputSize,inputSize) self:reset() end function Cosine:reset(stdv) if stdv then stdv = stdv * math.sqrt(3) else stdv = 1./math.sqrt(self.weight:size(1)) end self.weight:uniform(-stdv, stdv) end function Cosine:updateOutput(input) local inputSize = self.weight:size(2) local outputSize = self.weight:size(1) self._weightNorm = self._weightNorm or self.weight.new() self._inputNorm = self._inputNorm or self.weight.new() -- y_j = (w_j * x) / ( || w_j || * || x || ) self._weightNorm:norm(self.weight,2,2):add(1e-12) if input:dim() == 1 then self.output:resize(outputSize):zero() self.output:addmv(1, self.weight, input) self.__norm = input:norm()+1e-12 self.output:cdiv(self._weightNorm:view(outputSize)):div(self.__norm) elseif input:dim() == 2 then local batchSize = input:size(1) local nElement = self.output:nElement() self.output:resize(batchSize, outputSize) if self.output:nElement() ~= nElement then self.output:zero() end self.output:addmm(0, self.output, 1, input, self.weight:t()) self._inputNorm:norm(input,2,2):add(1e-12) self.output:cdiv(self._weightNorm:view(1,outputSize):expandAs(self.output)) self.output:cdiv(self._inputNorm:expandAs(self.output)) else error('input must be vector or matrix') end return self.output end function Cosine:updateGradInput(input, gradOutput) if not self.gradInput then return end local inputSize = self.weight:size(2) local outputSize = self.weight:size(1) --[[ dy_j w_ji x_i ---- = ------------------- - y_j --------- dx_i || w_j || * || x || || x ||^2 --]] local nElement = self.gradInput:nElement() self.gradInput:resizeAs(input) if self.gradInput:nElement() ~= nElement then self.gradInput:zero() end if input:dim() == 1 then self._weight = self._weight or input.new() self._weight:resizeAs(self.weight):copy(self.weight) self._weight:cdiv(self._weightNorm:expandAs(self.weight)) self._weight:div(self.__norm) self._weight:addr(1, self._weight, -1/(self.__norm*self.__norm), self.output, input) self.gradInput:addmv(0, 1, self._weight:t(), gradOutput) elseif input:dim() == 2 then local inputNorm = self._inputNorm:expandAs(input) local weightNorm = self._weightNorm:view(1,outputSize):expandAs(gradOutput) self.gradInput:copy(input):cdiv(inputNorm) self._gradOutput = self._gradOutput or gradOutput.new() self._gradOutput:resizeAs(gradOutput):copy(gradOutput) self._gradOutput:cmul(self.output) self._sum = self._sum or input.new() self._sum:sum(self._gradOutput, 2) self.gradInput:cmul(self._sum:expandAs(input)) self._gradOutput:resizeAs(gradOutput):copy(gradOutput) self._gradOutput:cdiv(weightNorm) self.gradInput:addmm(-1, self.gradInput, 1, self._gradOutput, self.weight) self.gradInput:cdiv(inputNorm) end return self.gradInput end function Cosine:accGradParameters(input, gradOutput, scale) scale = scale or 1 local inputSize = self.weight:size(2) local outputSize = self.weight:size(1) --[[ dy_j x_i w_ji ----- = ------------------- - y_j ----------- dw_ji || w_j || * || x || || w_j ||^2 --]] if input:dim() == 1 then self._gradOutput = self._gradOutput or gradOutput.new() self._gradOutput:resizeAs(gradOutput):copy(gradOutput) local weightNorm = self._weightNorm:view(outputSize) self._gradOutput:cdiv(weightNorm) self.gradWeight:addr(scale/self.__norm, self._gradOutput, input) self._gradOutput:cdiv(weightNorm) self._gradOutput:cmul(self.output) self._weight = self._weight or self.weight.new() self._weight:resizeAs(self._weight):copy(self.weight) self._weight:cmul(self._gradOutput:view(outputSize, 1):expandAs(self.weight)) self.gradWeight:add(-1, self._weight) elseif input:dim() == 2 then self._weight = self._weight or self.weight.new() self._weight:resizeAs(self.weight):copy(self.weight) self._gradOutput = self._gradOutput or gradOutput.new() self._gradOutput:resizeAs(gradOutput):copy(gradOutput) self._gradOutput:cmul(self.output) self._sum = self._sum or input.new() self._sum:sum(self._gradOutput, 1) local grad = self._sum[1] grad:cdiv(self._weightNorm:select(2,1)) self._weight:cmul(grad:view(outputSize,1):expandAs(self._weight)) local input_ = self._gradOutput input_:resizeAs(input):copy(input) input_:cdiv(self._inputNorm:expandAs(input)) self._weight:addmm(-1, self._weight, 1, gradOutput:t(), input_) self._weight:cdiv(self._weightNorm:expandAs(self._weight)) self.gradWeight:add(self._weight) else error"1D or 2D input expected" end end function Cosine:type(type, tensorCache) if type then -- prevent premature memory allocations self._input = nil self._weight = nil self._inputNorm = nil self._weightNorm = nil self._gradOutput = nil self._sum = nil end return parent.type(self, type, tensorCache) end function Cosine:clearState() nn.utils.clear(self, { '_input', '_weight', '_gradOutput', '_sum', '_inputNorm', '_weightNorm', }) return parent.clearState(self) end
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/luarocks/doc.lua
14
5076
--- Module implementing the LuaRocks "doc" command. -- Shows documentation for an installed rock. --module("luarocks.doc", package.seeall) local doc = {} package.loaded["luarocks.doc"] = doc local util = require("luarocks.util") local show = require("luarocks.show") local path = require("luarocks.path") local dir = require("luarocks.dir") local fetch = require("luarocks.fetch") local fs = require("luarocks.fs") local download = require("luarocks.download") doc.help_summary = "Show documentation for an installed rock." doc.help = [[ <argument> is an existing package name. Without any flags, tries to load the documentation using a series of heuristics. With these flags, return only the desired information: --home Open the home page of project. --list List documentation files only. For more information about a rock, see the 'show' command. ]] local function show_homepage(homepage, name, version) if not homepage then return nil, "No 'homepage' field in rockspec for "..name.." "..version end util.printout("Opening "..homepage.." ...") fs.browser(homepage) return true end local function try_to_open_homepage(name, version) local temp_dir, err = fs.make_temp_dir("doc-"..name.."-"..(version or "")) if not temp_dir then return nil, "Failed creating temporary directory: "..err end util.schedule_function(fs.delete, temp_dir) local ok, err = fs.change_dir(temp_dir) if not ok then return nil, err end local filename, err = download.download("rockspec", name, version) if not filename then return nil, err end local rockspec, err = fetch.load_local_rockspec(filename) if not rockspec then return nil, err end fs.pop_dir() local descript = rockspec.description or {} if not descript.homepage then return nil, "No homepage defined for "..name end return show_homepage(descript.homepage, name, version) end --- Driver function for "doc" command. -- @param name or nil: an existing package name. -- @param version string or nil: a version may also be passed. -- @return boolean: True if succeeded, nil on errors. function doc.run(...) local flags, name, version = util.parse_flags(...) if not name then return nil, "Argument missing. "..util.see_help("doc") end local iname, iversion, repo = show.pick_installed_rock(name, version, flags["tree"]) if not iname then util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") return try_to_open_homepage(name, version) end name, version = iname, iversion local rockspec, err = fetch.load_local_rockspec(path.rockspec_file(name, version, repo)) if not rockspec then return nil,err end local descript = rockspec.description or {} if flags["home"] then return show_homepage(descript.homepage, name, version) end local directory = path.install_dir(name,version,repo) local docdir local directories = { "doc", "docs" } for _, d in ipairs(directories) do local dirname = dir.path(directory, d) if fs.is_dir(dirname) then docdir = dirname break end end if not docdir then if descript.homepage and not flags["list"] then util.printout("Local documentation directory not found -- opening "..descript.homepage.." ...") fs.browser(descript.homepage) return true end return nil, "Documentation directory not found for "..name.." "..version end docdir = dir.normalize(docdir):gsub("/+", "/") local files = fs.find(docdir) local htmlpatt = "%.html?$" local extensions = { htmlpatt, "%.md$", "%.txt$", "%.textile$", "" } local basenames = { "index", "readme", "manual" } local porcelain = flags["porcelain"] if #files > 0 then util.title("Documentation files for "..name.." "..version, porcelain) if porcelain then for _, file in ipairs(files) do util.printout(docdir.."/"..file) end else util.printout(docdir.."/") for _, file in ipairs(files) do util.printout("\t"..file) end end end if flags["list"] then return true end for _, extension in ipairs(extensions) do for _, basename in ipairs(basenames) do local filename = basename..extension local found for _, file in ipairs(files) do if file:lower():match(filename) and ((not found) or #file < #found) then found = file end end if found then local pathname = dir.path(docdir, found) util.printout() util.printout("Opening "..pathname.." ...") util.printout() local ok = fs.browser(pathname) if not ok and not pathname:match(htmlpatt) then local fd = io.open(pathname, "r") util.printout(fd:read("*a")) fd:close() end return true end end end return true end return doc
mit
pillowthief/moonridge
lib/jumper/core/assert.lua
1
2547
-- Various assertion function for API methods argument-checking if (...) then -- Dependancies local _PATH = (...):gsub('%.core.assert$','') local Utils = require ('lib/jumper/core/utils') -- Local references local lua_type = type local floor = math.floor local concat = table.concat local next = next local pairs = pairs local getmetatable = getmetatable -- Is I an integer ? local function isInteger(i) return lua_type(i) ==('number') and (floor(i)==i) end -- Override lua_type to return integers local function type(v) return isInteger(v) and 'int' or lua_type(v) end -- Does the given array contents match a predicate type ? local function arrayContentsMatch(t,...) local n_count = Utils.arraySize(t) if n_count < 1 then return false end local init_count = t[0] and 0 or 1 local n_count = (t[0] and n_count-1 or n_count) local types = {...} if types then types = concat(types) end for i=init_count,n_count,1 do if not t[i] then return false end if types then if not types:match(type(t[i])) then return false end end end return true end -- Checks if arg is a valid array map local function isMap(m) if not arrayContentsMatch(m, 'table') then return false end local lsize = Utils.arraySize(m[next(m)]) for k,v in pairs(m) do if not arrayContentsMatch(m[k], 'string', 'int') then return false end if Utils.arraySize(v)~=lsize then return false end end return true end -- Checks if s is a valid string map local function isStringMap(s) if lua_type(s) ~= 'string' then return false end local w for row in s:gmatch('[^\n\r]+') do if not row then return false end w = w or #row if w ~= #row then return false end end return true end -- Does instance derive straight from class local function derives(instance, class) return getmetatable(instance) == class end -- Does instance inherits from class local function inherits(instance, class) return (getmetatable(getmetatable(instance)) == class) end -- Is arg a boolean local function isBoolean(b) return (b==true or b==false) end -- Is arg nil ? local function isNil(n) return (n==nil) end local function matchType(value, types) return types:match(type(value)) end return { arrayContentsMatch = arrayContentsMatch, derives = derives, inherits = inherits, isInteger = isInteger, isBool = isBoolean, isMap = isMap, isStrMap = isStringMap, isOutOfRange = isOutOfRange, isNil = isNil, type = type, matchType = matchType } end
mit
ZyX-I/luassert
src/languages/nl.lua
6
1453
local s = require('say') s:set_namespace('nl') s:set("assertion.same.positive", "Verwachtte objecten die vergelijkbaar zijn.\nAangeboden:\n%s\nVerwachtte:\n%s") s:set("assertion.same.negative", "Verwachtte objecten die niet vergelijkbaar zijn.\nAangeboden:\n%s\nVerwachtte niet:\n%s") s:set("assertion.equals.positive", "Verwachtte objecten die hetzelfde zijn.\nAangeboden:\n%s\nVerwachtte:\n%s") s:set("assertion.equals.negative", "Verwachtte objecten die niet hetzelfde zijn.\nAangeboden:\n%s\nVerwachtte niet:\n%s") s:set("assertion.unique.positive", "Verwachtte objecten die uniek zijn:\n%s") s:set("assertion.unique.negative", "Verwachtte objecten die niet uniek zijn:\n%s") s:set("assertion.error.positive", "Verwachtte een foutmelding.") s:set("assertion.error.negative", "Verwachtte geen foutmelding.\n%s") s:set("assertion.truthy.positive", "Verwachtte een 'warige' (thruthy) waarde, maar was:\n%s") s:set("assertion.truthy.negative", "Verwachtte een niet 'warige' (thruthy) waarde, maar was:\n%s") s:set("assertion.falsy.positive", "Verwachtte een 'onwarige' (falsy) waarde, maar was:\n%s") s:set("assertion.falsy.negative", "Verwachtte een niet 'onwarige' (falsy) waarde, maar was:\n%s") -- errors s:set("assertion.internal.argtolittle", "de '%s' functie verwacht minimaal %s parameters, maar kreeg er: %s") s:set("assertion.internal.badargtype", "bad argument #%s: de '%s' functie verwacht een %s als parameter, maar kreeg een: %s")
mit
cailyoung/CommandPost
src/extensions/cp/apple/finalcutpro/main/Browser.lua
1
7035
-------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- F I N A L C U T P R O A P I -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --- === cp.apple.finalcutpro.main.Browser === --- --- Browser Module. -------------------------------------------------------------------------------- -- -- EXTENSIONS: -- -------------------------------------------------------------------------------- local log = require("hs.logger").new("browser") local inspect = require("hs.inspect") local just = require("cp.just") local prop = require("cp.prop") local axutils = require("cp.ui.axutils") local PrimaryWindow = require("cp.apple.finalcutpro.main.PrimaryWindow") local SecondaryWindow = require("cp.apple.finalcutpro.main.SecondaryWindow") local LibrariesBrowser = require("cp.apple.finalcutpro.main.LibrariesBrowser") local MediaBrowser = require("cp.apple.finalcutpro.main.MediaBrowser") local GeneratorsBrowser = require("cp.apple.finalcutpro.main.GeneratorsBrowser") local CheckBox = require("cp.ui.CheckBox") -------------------------------------------------------------------------------- -- -- THE MODULE: -- -------------------------------------------------------------------------------- local Browser = {} -- TODO: Add documentation function Browser.matches(element) local checkBoxes = axutils.childrenWithRole(element, "AXCheckBox") return checkBoxes and #checkBoxes >= 3 end -- TODO: Add documentation function Browser:new(app) local o = {_app = app} return prop.extend(o, Browser) end -- TODO: Add documentation function Browser:app() return self._app end ----------------------------------------------------------------------- -- -- BROWSER UI: -- ----------------------------------------------------------------------- -- TODO: Add documentation function Browser:UI() return axutils.cache(self, "_ui", function() local app = self:app() return Browser._findBrowser(app:secondaryWindow(), app:primaryWindow()) end, Browser.matches) end -- TODO: Add documentation function Browser._findBrowser(...) for i = 1,select("#", ...) do local window = select(i, ...) if window then local ui = window:browserGroupUI() if ui then local browser = axutils.childMatching(ui, Browser.matches) if browser then return browser end end end end return nil end --- cp.apple.finalcutpro.main.Browser.isOnSecondary <cp.prop: boolean; read-only> --- Field --- Is the Browser on the Secondary Window? Browser.isOnSecondary = prop.new(function(self) local ui = self:UI() return ui and SecondaryWindow.matches(ui:window()) end):bind(Browser) --- cp.apple.finalcutpro.main.Browser <cp.prop: boolean; read-only> --- Field --- Is the Browser on the Primary Window? Browser.isOnPrimary = prop.new(function(self) local ui = self:UI() return ui and PrimaryWindow.matches(ui:window()) end):bind(Browser) --- cp.apple.finalcutpro.main.Browser <cp.prop: boolean; read-only> --- Field --- Is the Browser showing? Browser.isShowing = prop.new(function(self) return self:UI() ~= nil end):bind(Browser) -- TODO: Add documentation function Browser:showOnPrimary() -- show the parent. local menuBar = self:app():menuBar() -- if the browser is on the secondary, we need to turn it off before enabling in primary if self:isOnSecondary() then menuBar:checkMenu({"Window", "Show in Secondary Display", "Browser"}) end -- Then enable it in the primary if not self:isShowing() then menuBar:checkMenu({"Window", "Show in Workspace", "Browser"}) end return self end -- TODO: Add documentation function Browser:showOnSecondary() -- show the parent. local menuBar = self:app():menuBar() if not self:isOnSecondary() then menuBar:selectMenu({"Window", "Show in Secondary Display", "Browser"}) end return self end -- TODO: Add documentation function Browser:hide() if self:isShowing() then -- Uncheck it from the workspace self:app():menuBar():selectMenu({"Window", "Show in Workspace", "Browser"}) end return self end ----------------------------------------------------------------------- -- -- SECTIONS: -- ----------------------------------------------------------------------- -- TODO: Add documentation function Browser:showLibraries() if not self._showLibraries then self._showLibraries = CheckBox:new(self, function() local ui = self:UI() if ui and #ui > 3 then -- The library toggle is always the last element. return ui[#ui] end return nil end) end return self._showLibraries end -- TODO: Add documentation function Browser:showMedia() if not self._showMedia then self._showMedia = CheckBox:new(self, function() local ui = self:UI() if ui and #ui > 3 then -- The media toggle is always the second-last element. return ui[#ui-1] end return nil end) end return self._showMedia end -- TODO: Add documentation function Browser:showGenerators() if not self._showGenerators then self._showGenerators = CheckBox:new(self, function() local ui = self:UI() if ui and #ui > 3 then -- The generators toggle is always the third-last element. return ui[#ui-2] end return nil end) end return self._showGenerators end -- TODO: Add documentation function Browser:libraries() if not self._libraries then self._libraries = LibrariesBrowser:new(self) end return self._libraries end -- TODO: Add documentation function Browser:media() if not self._media then self._media = MediaBrowser:new(self) end return self._media end -- TODO: Add documentation function Browser:generators() if not self._generators then self._generators = GeneratorsBrowser:new(self) end return self._generators end -- TODO: Add documentation function Browser:saveLayout() local layout = {} if self:isShowing() then layout.showing = true layout.onPrimary = self:isOnPrimary() layout.onSecondary = self:isOnSecondary() layout.showLibraries = self:showLibraries():saveLayout() layout.showMedia = self:showMedia():saveLayout() layout.showGenerators = self:showGenerators():saveLayout() layout.libraries = self:libraries():saveLayout() layout.media = self:media():saveLayout() layout.generators = self:generators():saveLayout() end return layout end -- TODO: Add documentation function Browser:loadLayout(layout) if layout and layout.showing then if layout.onPrimary then self:showOnPrimary() end if layout.onSecondary then self:showOnSecondary() end self:generators():loadLayout(layout.generators) self:media():loadLayout(layout.media) self:libraries():loadLayout(layout.libraries) self:showGenerators():loadLayout(layout.showGenerators) self:showMedia():loadLayout(layout.showMedia) self:showLibraries():loadLayout(layout.showLibraries) end end return Browser
mit
rlcevg/Zero-K
LuaUI/i18nlib/spec/i18n_interpolate_spec.lua
21
2228
require 'spec.fixPackagePath' local interpolate = require 'i18n.interpolate' describe('i18n.interpolate', function() it("exists", function() assert_equal('function', type(interpolate)) end) it("performs standard interpolation via string.format", function() assert_equal("My name is John, I am 13", interpolate("My name is %s, I am %d", {"John", 13})) end) describe("When interpolating with hash values", function() it("converts non-existing items in nil values without error", function() assert_equal("Nil = nil", interpolate("Nil = %{null}")) end) it("converts variables in stringifield values", function() assert_equal("My name is John, I am 13", interpolate("My name is %{name}, I am %{age}", {name = "John", age = 13})) end) it("ignores spaces inside the brackets", function() assert_equal("My name is John, I am 13", interpolate("My name is %{ name }, I am %{ age }", {name = "John", age = 13})) end) it("is escaped via double %%", function() assert_equal("I am a %{blue} robot.", interpolate("I am a %%{blue} robot.")) end) end) describe("When interpolating with hash values and formats", function() it("converts non-existing items in nil values without error", function() assert_equal("Nil = nil", interpolate("Nil = %<null>.s")) end) it("converts variables in stringifield values", function() assert_equal("My name is John, I am 13", interpolate("My name is %<name>.s, I am %<age>.d", {name = "John", age = 13})) end) it("ignores spaces inside the brackets", function() assert_equal("My name is John, I am 13", interpolate("My name is %< name >.s, I am %< age >.d", {name = "John", age = 13})) end) it("is escaped via double %%", function() assert_equal("I am a %<blue>.s robot.", interpolate("I am a %%<blue>.s robot.")) end) end) it("Interpolates everything at the same time", function() assert_equal('A nil ref and %<escape>.d and spaced and "quoted" and something', interpolate("A %{null} ref and %%<escape>.d and %{ spaced } and %<quoted>.q and %s", { "something", spaced = "spaced", quoted = "quoted" }) ) end) end)
gpl-2.0
kindy/ltp
ltp.lua
1
4887
#!/usr/bin/env lua -- -- Copyright 2007-2009 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. -- package.path = "@LTP_LIB_DIR@/?.lua;" .. package.path -- We want ltp to be a global variable so it will be available for use -- by templates and environment files. ltp = require('ltp.template') local function usage(program_name) io.stderr:write("usage: ", program_name, " [options] template_file [env_file1 env_file2 ...]\n") io.stderr:write([[ Options: -c Compiles template to Lua code. -C Compiles template to Lua code, omitting the function wrapper. -e code Executes Lua code within the template execution environment immediately before executing the template. -g Merges global environment into rendering environment. -h,--help Prints this help message. -I directory Adds a directory to the search path for require directives. -n # Performs successive expansions of template output, treating the output as a new template, for a total of # passes. This allows the use of embedded expressions. By default, only a single pass (# = 1) is made (i.e., only the original template is evaluated). A value of 0 may be specified to cause as many passes to be performed as necessary so that no embedded expressions remain in the output. -t start_lua_token end_lua_token Specifies the start and end tokens that demarcate embedded Lua code. The defaults are '<?lua' and '?>'. -v,--version Prints version information. --lib-dir Prints the directory name containing the ltp library modules. --install-dir Prints the directory name used as the ltp installation prefix. ]]) end local function version() io.stdout:write( [[ ltp version: @VERSION@ build: @BUILD@ Copyright 2007-2009 Savarese Software Research Corporation. All Rights Reserved. ]]) end local function main(arg) local CompileFlags = { None = { }, WithWrapper = { }, WithoutWrapper = { } } local i = 1 local merge_global = false local compile_flags = CompileFlags.None; local start_lua, end_lua = "<?lua", "?>" local num_passes = 1 local env_code = { } while i <= #arg do if arg[i] == "-h" or arg[i] == "--help" then usage(arg[0]) os.exit(1) elseif arg[i] == "-v" or arg[i] == "--version" then version() os.exit(1) elseif arg[i] == "-g" then merge_global = true i = i + 1 elseif arg[i] == "-c" then compile_flags = CompileFlags.WithWrapper i = i + 1 elseif arg[i] == "-C" then compile_flags = CompileFlags.WithoutWrapper i = i + 1 elseif arg[i] == "-n" then num_passes = tonumber(arg[i + 1]) i = i + 2 elseif arg[i] == "-t" then start_lua, end_lua = arg[i+1], arg[i+2] i = i + 3 if not start_lua or not end_lua then break end elseif arg[i] == "-I" then local dir = arg[i+1] i = i + 2 if not dir then break else package.path = dir .. "/?.lua;" .. package.path end elseif arg[i] == "-e" then local code = arg[i+1] i = i + 2 if not code then break else table.insert(env_code, code) end elseif arg[i] == "--lib-dir" then io.stdout:write("@LTP_LIB_DIR@\n") os.exit(0) elseif arg[i] == "--install-dir" then io.stdout:write("@LTP_INST_DIR@\n") os.exit(0) else break end end if(not num_passes or num_passes < 0) then io.stderr:write("-n arg must be >= 1.\n") os.exit(1); end if #arg - i < 0 then io.stderr:write("Insufficient arguments.\n"); usage(arg[0]) os.exit(1) end local template_file, env_files = arg[i], ltp.slice(arg, i+1) if compile_flags == CompileFlags.None then ltp.render(io.stdout, num_passes, template_file, merge_global, env_files, start_lua, end_lua, env_code) elseif compile_flags == CompileFlags.WithWrapper then ltp.compile_as_function(io.stdout, template_file, start_lua, end_lua) elseif compile_flags == CompileFlags.WithoutWrapper then ltp.compile(io.stdout, template_file, start_lua, end_lua) end end main(arg)
apache-2.0
EliHar/Pattern_recognition
torch1/pkg/torch/torchcwrap.lua
7
17895
local wrap = require 'cwrap' local types = wrap.types types.Tensor = { helpname = function(arg) if arg.dim then return string.format("Tensor~%dD", arg.dim) else return "Tensor" end end, declare = function(arg) local txt = {} table.insert(txt, string.format("THTensor *arg%d = NULL;", arg.i)) if arg.returned then table.insert(txt, string.format("int arg%d_idx = 0;", arg.i)); end return table.concat(txt, '\n') end, check = function(arg, idx) if arg.dim then return string.format("(arg%d = luaT_toudata(L, %d, torch_Tensor)) && (arg%d->nDimension == %d)", arg.i, idx, arg.i, arg.dim) else return string.format("(arg%d = luaT_toudata(L, %d, torch_Tensor))", arg.i, idx) end end, read = function(arg, idx) if arg.returned then return string.format("arg%d_idx = %d;", arg.i, idx) end end, init = function(arg) if type(arg.default) == 'boolean' then return string.format('arg%d = THTensor_(new)();', arg.i) elseif type(arg.default) == 'number' then return string.format('arg%d = %s;', arg.i, arg.args[arg.default]:carg()) else error('unknown default tensor type value') end end, carg = function(arg) return string.format('arg%d', arg.i) end, creturn = function(arg) return string.format('arg%d', arg.i) end, precall = function(arg) local txt = {} if arg.default and arg.returned then table.insert(txt, string.format('if(arg%d_idx)', arg.i)) -- means it was passed as arg table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) table.insert(txt, string.format('else')) if type(arg.default) == 'boolean' then -- boolean: we did a new() table.insert(txt, string.format('luaT_pushudata(L, arg%d, torch_Tensor);', arg.i)) else -- otherwise: point on default tensor --> retain table.insert(txt, string.format('{')) table.insert(txt, string.format('THTensor_(retain)(arg%d);', arg.i)) -- so we need a retain table.insert(txt, string.format('luaT_pushudata(L, arg%d, torch_Tensor);', arg.i)) table.insert(txt, string.format('}')) end elseif arg.default then -- we would have to deallocate the beast later if we did a new -- unlikely anyways, so i do not support it for now if type(arg.default) == 'boolean' then error('a tensor cannot be optional if not returned') end elseif arg.returned then table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) end return table.concat(txt, '\n') end, postcall = function(arg) local txt = {} if arg.creturned then -- this next line is actually debatable table.insert(txt, string.format('THTensor_(retain)(arg%d);', arg.i)) table.insert(txt, string.format('luaT_pushudata(L, arg%d, torch_Tensor);', arg.i)) end return table.concat(txt, '\n') end } types.Generator = { helpname = function(arg) return "Generator" end, declare = function(arg) return string.format("THGenerator *arg%d = NULL;", arg.i) end, check = function(arg, idx) return string.format("(arg%d = luaT_toudata(L, %d, torch_Generator))", arg.i, idx) end, read = function(arg, idx) end, init = function(arg) local text = {} -- If no generator is supplied, pull the default out of the torch namespace. table.insert(text, 'lua_getglobal(L,"torch");') table.insert(text, string.format('arg%d = luaT_getfieldcheckudata(L, -1, "_gen", torch_Generator);', arg.i)) table.insert(text, 'lua_pop(L, 2);') return table.concat(text, '\n') end, carg = function(arg) return string.format('arg%d', arg.i) end, creturn = function(arg) return string.format('arg%d', arg.i) end, precall = function(arg) end, postcall = function(arg) end } types.IndexTensor = { helpname = function(arg) return "LongTensor" end, declare = function(arg) local txt = {} table.insert(txt, string.format("THLongTensor *arg%d = NULL;", arg.i)) if arg.returned then table.insert(txt, string.format("int arg%d_idx = 0;", arg.i)); end return table.concat(txt, '\n') end, check = function(arg, idx) return string.format('(arg%d = luaT_toudata(L, %d, "torch.LongTensor"))', arg.i, idx) end, read = function(arg, idx) local txt = {} if not arg.noreadadd then table.insert(txt, string.format("THLongTensor_add(arg%d, arg%d, -1);", arg.i, arg.i)); end if arg.returned then table.insert(txt, string.format("arg%d_idx = %d;", arg.i, idx)) end return table.concat(txt, '\n') end, init = function(arg) return string.format('arg%d = THLongTensor_new();', arg.i) end, carg = function(arg) return string.format('arg%d', arg.i) end, creturn = function(arg) return string.format('arg%d', arg.i) end, precall = function(arg) local txt = {} if arg.default and arg.returned then table.insert(txt, string.format('if(arg%d_idx)', arg.i)) -- means it was passed as arg table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) table.insert(txt, string.format('else')) -- means we did a new() table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.LongTensor");', arg.i)) elseif arg.default then error('a tensor cannot be optional if not returned') elseif arg.returned then table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) end return table.concat(txt, '\n') end, postcall = function(arg) local txt = {} if arg.creturned or arg.returned then table.insert(txt, string.format("THLongTensor_add(arg%d, arg%d, 1);", arg.i, arg.i)); end if arg.creturned then -- this next line is actually debatable table.insert(txt, string.format('THLongTensor_retain(arg%d);', arg.i)) table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.LongTensor");', arg.i)) end return table.concat(txt, '\n') end } for _,typename in ipairs({"ByteTensor", "CharTensor", "ShortTensor", "IntTensor", "LongTensor", "FloatTensor", "DoubleTensor"}) do types[typename] = { helpname = function(arg) if arg.dim then return string.format('%s~%dD', typename, arg.dim) else return typename end end, declare = function(arg) local txt = {} table.insert(txt, string.format("TH%s *arg%d = NULL;", typename, arg.i)) if arg.returned then table.insert(txt, string.format("int arg%d_idx = 0;", arg.i)); end return table.concat(txt, '\n') end, check = function(arg, idx) if arg.dim then return string.format('(arg%d = luaT_toudata(L, %d, "torch.%s")) && (arg%d->nDimension == %d)', arg.i, idx, typename, arg.i, arg.dim) else return string.format('(arg%d = luaT_toudata(L, %d, "torch.%s"))', arg.i, idx, typename) end end, read = function(arg, idx) if arg.returned then return string.format("arg%d_idx = %d;", arg.i, idx) end end, init = function(arg) if type(arg.default) == 'boolean' then return string.format('arg%d = TH%s_new();', arg.i, typename) elseif type(arg.default) == 'number' then return string.format('arg%d = %s;', arg.i, arg.args[arg.default]:carg()) else error('unknown default tensor type value') end end, carg = function(arg) return string.format('arg%d', arg.i) end, creturn = function(arg) return string.format('arg%d', arg.i) end, precall = function(arg) local txt = {} if arg.default and arg.returned then table.insert(txt, string.format('if(arg%d_idx)', arg.i)) -- means it was passed as arg table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) table.insert(txt, string.format('else')) if type(arg.default) == 'boolean' then -- boolean: we did a new() table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.%s");', arg.i, typename)) else -- otherwise: point on default tensor --> retain table.insert(txt, string.format('{')) table.insert(txt, string.format('TH%s_retain(arg%d);', typename, arg.i)) -- so we need a retain table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.%s");', arg.i, typename)) table.insert(txt, string.format('}')) end elseif arg.default then -- we would have to deallocate the beast later if we did a new -- unlikely anyways, so i do not support it for now if type(arg.default) == 'boolean' then error('a tensor cannot be optional if not returned') end elseif arg.returned then table.insert(txt, string.format('lua_pushvalue(L, arg%d_idx);', arg.i)) end return table.concat(txt, '\n') end, postcall = function(arg) local txt = {} if arg.creturned then -- this next line is actually debatable table.insert(txt, string.format('TH%s_retain(arg%d);', typename, arg.i)) table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.%s");', arg.i, typename)) end return table.concat(txt, '\n') end } types[typename .. 'Array'] = { helpname = function(arg) return string.format('{%s+}', typename) end, declare = function(arg) local txt = {} table.insert(txt, string.format('TH%s **arg%d_data = NULL;', typename, arg.i)) table.insert(txt, string.format('long arg%d_size = 0;', arg.i)) table.insert(txt, string.format('int arg%d_i = 0;', arg.i)) return table.concat(txt, '\n') end, check = function(arg, idx) return string.format('torch_isnonemptytable(L, %d)', idx) end, read = function(arg, idx) local txt = {} -- Iterate over the array to find its length, leave elements on stack. table.insert(txt, string.format('do')) table.insert(txt, string.format('{')) table.insert(txt, string.format(' arg%d_size++;', arg.i)) table.insert(txt, string.format(' lua_checkstack(L, 1);')) table.insert(txt, string.format(' lua_rawgeti(L, %d, arg%d_size);', idx, arg.i)) table.insert(txt, string.format('}')) table.insert(txt, string.format('while (!lua_isnil(L, -1));')) table.insert(txt, string.format('arg%d_size--;', arg.i)) -- Pop nil element from stack. table.insert(txt, string.format('lua_pop(L, 1);')) -- Allocate tensor pointers and read values from stack backwards. table.insert(txt, string.format('arg%d_data = (TH%s**)THAlloc(arg%d_size * sizeof(TH%s*));', arg.i, typename, arg.i, typename)) table.insert(txt, string.format('for (arg%d_i = arg%d_size - 1; arg%d_i >= 0; arg%d_i--)', arg.i, arg.i, arg.i, arg.i)) table.insert(txt, string.format('{')) table.insert(txt, string.format(' if (!(arg%d_data[arg%d_i] = luaT_toudata(L, -1, "torch.%s")))', arg.i, arg.i, typename)) table.insert(txt, string.format(' luaL_error(L, "expected %s in tensor array");', typename)) table.insert(txt, string.format(' lua_pop(L, 1);')) table.insert(txt, string.format('}')) table.insert(txt, string.format('')) return table.concat(txt, '\n') end, init = function(arg) end, carg = function(arg) return string.format('arg%d_data,arg%d_size', arg.i, arg.i) end, creturn = function(arg) error('TensorArray cannot be returned.') end, precall = function(arg) end, postcall = function(arg) return string.format('THFree(arg%d_data);', arg.i) end } end types.LongArg = { vararg = true, helpname = function(arg) return "(LongStorage | dim1 [dim2...])" end, declare = function(arg) return string.format("THLongStorage *arg%d = NULL;", arg.i) end, init = function(arg) if arg.default then error('LongArg cannot have a default value') end end, check = function(arg, idx) return string.format("torch_islongargs(L, %d)", idx) end, read = function(arg, idx) return string.format("arg%d = torch_checklongargs(L, %d);", arg.i, idx) end, carg = function(arg, idx) return string.format('arg%d', arg.i) end, creturn = function(arg, idx) return string.format('arg%d', arg.i) end, precall = function(arg) local txt = {} if arg.returned then table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.LongStorage");', arg.i)) end return table.concat(txt, '\n') end, postcall = function(arg) local txt = {} if arg.creturned then -- this next line is actually debatable table.insert(txt, string.format('THLongStorage_retain(arg%d);', arg.i)) table.insert(txt, string.format('luaT_pushudata(L, arg%d, "torch.LongStorage");', arg.i)) end if not arg.returned and not arg.creturned then table.insert(txt, string.format('THLongStorage_free(arg%d);', arg.i)) end return table.concat(txt, '\n') end } types.charoption = { helpname = function(arg) if arg.values then return "(" .. table.concat(arg.values, '|') .. ")" end end, declare = function(arg) local txt = {} table.insert(txt, string.format("const char *arg%d = NULL;", arg.i)) if arg.default then table.insert(txt, string.format("char arg%d_default = '%s';", arg.i, arg.default)) end return table.concat(txt, '\n') end, init = function(arg) return string.format("arg%d = &arg%d_default;", arg.i, arg.i) end, check = function(arg, idx) local txt = {} local txtv = {} table.insert(txt, string.format('(arg%d = lua_tostring(L, %d)) && (', arg.i, idx)) for _,value in ipairs(arg.values) do table.insert(txtv, string.format("*arg%d == '%s'", arg.i, value)) end table.insert(txt, table.concat(txtv, ' || ')) table.insert(txt, ')') return table.concat(txt, '') end, read = function(arg, idx) end, carg = function(arg, idx) return string.format('arg%d', arg.i) end, creturn = function(arg, idx) end, precall = function(arg) end, postcall = function(arg) end }
mit
cloudkick/ck-agent
extern/luasocket/src/socket.lua
146
4061
----------------------------------------------------------------------------- -- LuaSocket helper module -- Author: Diego Nehab -- RCS ID: $Id: socket.lua,v 1.22 2005/11/22 08:33:29 diego Exp $ ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- Declare module and import dependencies ----------------------------------------------------------------------------- local base = _G local string = require("string") local math = require("math") local socket = require("socket.core") module("socket") ----------------------------------------------------------------------------- -- Exported auxiliar functions ----------------------------------------------------------------------------- function connect(address, port, laddress, lport) local sock, err = socket.tcp() if not sock then return nil, err end if laddress then local res, err = sock:bind(laddress, lport, -1) if not res then return nil, err end end local res, err = sock:connect(address, port) if not res then return nil, err end return sock end function bind(host, port, backlog) local sock, err = socket.tcp() if not sock then return nil, err end sock:setoption("reuseaddr", true) local res, err = sock:bind(host, port) if not res then return nil, err end res, err = sock:listen(backlog) if not res then return nil, err end return sock end try = newtry() function choose(table) return function(name, opt1, opt2) if base.type(name) ~= "string" then name, opt1, opt2 = "default", name, opt1 end local f = table[name or "nil"] if not f then base.error("unknown key (".. base.tostring(name) ..")", 3) else return f(opt1, opt2) end end end ----------------------------------------------------------------------------- -- Socket sources and sinks, conforming to LTN12 ----------------------------------------------------------------------------- -- create namespaces inside LuaSocket namespace sourcet = {} sinkt = {} BLOCKSIZE = 2048 sinkt["close-when-done"] = function(sock) return base.setmetatable({ getfd = function() return sock:getfd() end, dirty = function() return sock:dirty() end }, { __call = function(self, chunk, err) if not chunk then sock:close() return 1 else return sock:send(chunk) end end }) end sinkt["keep-open"] = function(sock) return base.setmetatable({ getfd = function() return sock:getfd() end, dirty = function() return sock:dirty() end }, { __call = function(self, chunk, err) if chunk then return sock:send(chunk) else return 1 end end }) end sinkt["default"] = sinkt["keep-open"] sink = choose(sinkt) sourcet["by-length"] = function(sock, length) return base.setmetatable({ getfd = function() return sock:getfd() end, dirty = function() return sock:dirty() end }, { __call = function() if length <= 0 then return nil end local size = math.min(socket.BLOCKSIZE, length) local chunk, err = sock:receive(size) if err then return nil, err end length = length - string.len(chunk) return chunk end }) end sourcet["until-closed"] = function(sock) local done return base.setmetatable({ getfd = function() return sock:getfd() end, dirty = function() return sock:dirty() end }, { __call = function() if done then return nil end local chunk, err, partial = sock:receive(socket.BLOCKSIZE) if not err then return chunk elseif err == "closed" then sock:close() done = 1 return partial else return nil, err end end }) end sourcet["default"] = sourcet["until-closed"] source = choose(sourcet)
apache-2.0
stas2z/openwrt-witi
package/luci/applications/luci-app-vnstat/luasrc/model/cbi/vnstat.lua
78
1816
-- Copyright 2010-2011 Jo-Philipp Wich <jow@openwrt.org> -- Licensed to the public under the Apache License 2.0. local utl = require "luci.util" local sys = require "luci.sys" local fs = require "nixio.fs" local nw = require "luci.model.network" local dbdir, line for line in io.lines("/etc/vnstat.conf") do dbdir = line:match("^%s*DatabaseDir%s+[\"'](%S-)[\"']") if dbdir then break end end dbdir = dbdir or "/var/lib/vnstat" m = Map("vnstat", translate("VnStat"), translate("VnStat is a network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s).")) m.submit = translate("Restart VnStat") m.reset = false nw.init(luci.model.uci.cursor_state()) local ifaces = { } local enabled = { } local iface if fs.access(dbdir) then for iface in fs.dir(dbdir) do if iface:sub(1,1) ~= '.' then ifaces[iface] = iface enabled[iface] = iface end end end for _, iface in ipairs(sys.net.devices()) do ifaces[iface] = iface end local s = m:section(TypedSection, "vnstat") s.anonymous = true s.addremove = false mon_ifaces = s:option(Value, "interface", translate("Monitor selected interfaces")) mon_ifaces.template = "cbi/network_ifacelist" mon_ifaces.widget = "checkbox" mon_ifaces.cast = "table" mon_ifaces.noinactive = true mon_ifaces.nocreate = true function mon_ifaces.write(self, section, val) local i local s = { } if val then for _, i in ipairs(type(val) == "table" and val or { val }) do s[i] = true end end for i, _ in pairs(ifaces) do if not s[i] then fs.unlink(dbdir .. "/" .. i) fs.unlink(dbdir .. "/." .. i) end end if next(s) then m.uci:set_list("vnstat", section, "interface", utl.keys(s)) else m.uci:delete("vnstat", section, "interface") end end mon_ifaces.remove = mon_ifaces.write return m
gpl-2.0
anholt/ValyriaTear
dat/maps/layna_forest/layna_forest_south_west_map.lua
4
94595
map_data = {} -- The number of rows, and columns that compose the map map_data.num_tile_cols = 64 map_data.num_tile_rows = 48 -- The tilesets definition files used. map_data.tileset_filenames = {} map_data.tileset_filenames[1] = "dat/tilesets/wood_tileset.lua" -- The map grid to indicate walkability. 0 is walkable, 1 is not. map_data.map_grid = {} map_data.map_grid[0] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -- The tile layers. The numbers are indeces to the tile_mappings table. map_data.layers = {} map_data.layers[0] = {} map_data.layers[0].type = "ground" map_data.layers[0].name = "Background" map_data.layers[0][0] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 18, 20, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 19, 36, 64, 65, 65, 65, 65 } map_data.layers[0][1] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 18, 20, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 36, 64, 65, 65, 65, 65, 65 } map_data.layers[0][2] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 18, 20, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 20, 48, 64, 65, 65, 65, 65, 65 } map_data.layers[0][3] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 2, 19, 36, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 2, 19, 36, 64, 65, 65, 65, 65, 65, 65 } map_data.layers[0][4] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 18, 20, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 3, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][5] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 18, 36, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 81, 81, 81, 81, 81, 2, 19, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][6] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 2, 20, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 3, 3, 3, 3, 4, 2, 19, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][7] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 81, 18, 20, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 19, 19, 35, 35, 35, 35, 35, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][8] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 81, 81, 81, 81, 81, 81, 81, 81, 82, 2, 3, 19, 19, 3, 4, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 2, 19, 35, 36, 49, 49, 49, 49, 49, 49, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][9] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 82, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 19, 19, 36, 0, 34, 19, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 0, 34, 36, 48, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][10] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 19, 19, 36, 34, 35, 35, 35, 35, 35, 35, 35, 36, 49, 49, 49, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 49, 49, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][11] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 82, 18, 19, 36, 49, 49, 49, 49, 49, 49, 49, 49, 49, 64, 65, 65, 65, 66, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][12] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][13] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][14] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 20, 48, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][15] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 64, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][16] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][17] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][18] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][19] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 82, 2, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][20] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 82, 2, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][21] = { 65, 65, 65, 65, 65, 65, 65, 66, 81, 82, 2, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][22] = { 65, 65, 65, 65, 65, 65, 66, 82, 2, 3, 36, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][23] = { 65, 65, 65, 65, 65, 66, 82, 2, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][24] = { 65, 65, 65, 65, 66, 82, 2, 36, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][25] = { 65, 65, 65, 66, 82, 2, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][26] = { 65, 65, 65, 66, 2, 19, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][27] = { 65, 65, 65, 66, 18, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][28] = { 65, 65, 65, 66, 18, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 3, 3, 3, 3, 3, 3, 3, 4, 0, 2, 4, 81, 81, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][29] = { 65, 65, 65, 66, 18, 36, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 82, 34, 35, 35, 35, 35, 35, 35, 35, 36, 49, 34, 36, 2, 4, 2, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][30] = { 65, 65, 65, 66, 18, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 81, 82, 2, 3, 4, 0, 0, 48, 49, 49, 49, 49, 64, 65, 66, 49, 34, 35, 35, 36, 80, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][31] = { 65, 65, 65, 66, 34, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 4, 0, 0, 34, 19, 19, 4, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 49, 49, 0, 2, 4, 81, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][32] = { 65, 65, 65, 65, 66, 18, 4, 64, 65, 65, 65, 65, 66, 81, 81, 81, 82, 34, 36, 49, 49, 49, 34, 35, 19, 4, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 17, 18, 20, 0, 2, 4, 81, 81, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][33] = { 65, 65, 65, 65, 66, 34, 19, 4, 81, 81, 81, 81, 82, 2, 3, 4, 48, 49, 64, 65, 65, 65, 66, 49, 34, 19, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 49, 34, 36, 0, 2, 4, 80, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][34] = { 65, 65, 65, 65, 65, 66, 34, 36, 2, 3, 3, 4, 0, 34, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 66, 34, 20, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 2, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][35] = { 65, 65, 65, 65, 65, 65, 66, 49, 34, 36, 34, 36, 49, 49, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 20, 80, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][36] = { 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 20, 64, 65, 65, 65, 65, 65, 65, 65, 66, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 2, 4, 80, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][37] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 18, 4, 64, 65, 65, 65, 65, 65, 65, 66, 2, 4, 0, 0, 64, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 2, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][38] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 81, 64, 65, 65, 66, 81, 64, 65, 65, 65, 65, 65, 65, 66, 18, 20, 64, 65, 65, 65, 65, 65, 65, 66, 34, 19, 3, 4, 80, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 19, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][39] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 2, 4, 81, 81, 2, 4, 64, 65, 65, 65, 65, 65, 65, 66, 34, 20, 64, 65, 65, 65, 65, 65, 65, 65, 66, 34, 35, 35, 3, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 36, 80, 81, 81, 81, 64, 65, 65, 65, 65 } map_data.layers[0][40] = { 65, 65, 65, 65, 65, 65, 65, 66, 81, 64, 65, 65, 66, 34, 35, 3, 3, 35, 36, 64, 65, 65, 65, 65, 65, 65, 66, 0, 18, 4, 64, 65, 65, 65, 65, 65, 65, 65, 66, 49, 49, 34, 36, 64, 65, 65, 66, 81, 64, 65, 65, 65, 65, 66, 50, 2, 4, 2, 4, 80, 64, 65, 65, 66 } map_data.layers[0][41] = { 65, 65, 65, 65, 65, 65, 66, 2, 4, 64, 65, 65, 65, 66, 49, 34, 36, 0, 49, 64, 65, 65, 65, 65, 65, 65, 65, 66, 18, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 2, 4, 64, 65, 65, 65, 65, 65, 66, 34, 36, 34, 19, 4, 80, 81, 81, 2 } map_data.layers[0][42] = { 65, 65, 65, 65, 65, 65, 66, 18, 36, 64, 65, 65, 65, 65, 65, 65, 66, 64, 65, 65, 65, 66, 81, 64, 65, 65, 65, 66, 34, 20, 80, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 34, 20, 64, 65, 65, 65, 65, 65, 65, 66, 49, 50, 34, 36, 2, 4, 0, 18 } map_data.layers[0][43] = { 65, 65, 65, 65, 65, 65, 66, 18, 4, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 64, 65, 65, 65, 65, 2, 20, 0, 80, 64, 65, 66, 64, 65, 66, 64, 65, 65, 65, 65, 65, 65, 66, 2, 20, 64, 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 50, 34, 36, 49, 34 } map_data.layers[0][44] = { 65, 65, 65, 65, 65, 65, 66, 34, 36, 65, 65, 65, 65, 65, 66, 81, 81, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 34, 36, 49, 49, 2, 4, 2, 4, 0, 2, 4, 0, 0, 81, 81, 81, 81, 82, 34, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 64, 65, 66 } map_data.layers[0][45] = { 65, 65, 65, 65, 65, 65, 65, 66, 64, 65, 65, 65, 65, 66, 2, 3, 3, 4, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 64, 65, 65, 34, 36, 34, 36, 0, 34, 36, 0, 2, 3, 3, 3, 4, 48, 49, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][46] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 34, 35, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 49, 34, 35, 35, 35, 36, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[0][47] = { 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 0, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 0, 64, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } map_data.layers[1] = {} map_data.layers[1].type = "ground" map_data.layers[1].name = "Background 2" map_data.layers[1][0] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1 } map_data.layers[1][1] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][2] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, 14, -1, -1, -1, -1, -1 } map_data.layers[1][3] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 13, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, 47, -1, -1, 14, -1, -1, -1, -1, -1, -1 } map_data.layers[1][4] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][5] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, 47, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][6] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][7] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, 47, 45, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][8] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][9] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][11] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][12] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][13] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][14] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][15] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 14, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][18] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][19] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][20] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][21] = { -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][22] = { -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, 13, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][23] = { -1, -1, -1, -1, -1, 46, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][24] = { -1, -1, -1, -1, 46, -1, -1, 13, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][25] = { -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][26] = { -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][27] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][28] = { -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][29] = { -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, 15, -1, -1, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][30] = { -1, -1, -1, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 14, -1, 15, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][31] = { -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, 50, -1, 45, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][32] = { -1, -1, -1, -1, -1, -1, 45, 46, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, 13, -1, -1, -1, 15, -1, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, -1, -1, 45, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][33] = { -1, -1, -1, -1, 14, 15, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, 14, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 14, 14, -1, 14, 14, 15, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][34] = { -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 14, 15, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][35] = { -1, -1, -1, -1, -1, -1, 14, -1, 15, -1, -1, 13, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][36] = { -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, 14, 14, 15, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][37] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, 45, 81, 81, 46, -1, -1, -1, -1, -1, -1, -1, 14, 14, 15, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][38] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, 46, -1, -1, 46, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][39] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1 } map_data.layers[1][40] = { -1, -1, -1, -1, -1, -1, -1, 46, -1, 46, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, 14, 14, 14, -1, -1, 46, -1, 46, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, 46, -1, -1, 46 } map_data.layers[1][41] = { -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, 14, -1, 14, 15, 13, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, 47 } map_data.layers[1][42] = { -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, 14, 14, -1, -1, -1, 46, -1, 46, -1, -1, -1, 14, 15, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][43] = { -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 14, -1, -1, -1, -1, 31, -1, -1, -1, 46, -1, 46, 46, -1, 46, 46, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, 13, -1, 15 } map_data.layers[1][44] = { -1, -1, -1, -1, -1, -1, 14, 15, 29, -1, -1, -1, -1, -1, 46, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, -1, 45, 46, 47, 45, 81, 47, 45, 81, 81, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 14, -1, 14 } map_data.layers[1][45] = { -1, -1, -1, -1, -1, -1, -1, 14, 14, -1, -1, -1, -1, 46, 47, -1, -1, 45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 14, -1, -1, 31, 14, 14, 14, 14, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][46] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 13, 14, 14, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[1][47] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2] = {} map_data.layers[2].type = "ground" map_data.layers[2].name = "Background 3" map_data.layers[2][0] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][1] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][2] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][3] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][4] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][5] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][6] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][7] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][8] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][9] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][11] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][12] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][13] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][14] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][15] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 47, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][18] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][19] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][20] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][21] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][22] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][23] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][24] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][25] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][26] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][27] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][28] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][29] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][30] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][31] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][32] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][33] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][34] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][35] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][36] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][37] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][38] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][39] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][40] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][41] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][42] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][43] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][44] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][45] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][46] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[2][47] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3] = {} map_data.layers[3].type = "sky" map_data.layers[3].name = "Sky" map_data.layers[3][0] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][1] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][2] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][3] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][4] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][5] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][6] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][7] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][8] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][9] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][11] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][12] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][13] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][14] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][15] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][18] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][19] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][20] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][21] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][22] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][23] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][24] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][25] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][26] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][27] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][28] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][29] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][30] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][31] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][32] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][33] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][34] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][35] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][36] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][37] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][38] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][39] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][40] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][41] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][42] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][43] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][44] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][45] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][46] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } map_data.layers[3][47] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
gpl-2.0
medialab-prado/Interactivos-15-Ego
minetest-ego/games/adventuretest/mods/bucket/init.lua
4
5189
-- Minetest 0.4 mod: bucket -- See README.txt for licensing and other information. local LIQUID_MAX = 8 --The number of water levels when liquid_finite is enabled minetest.register_alias("bucket", "bucket:bucket_empty") minetest.register_alias("bucket_water", "bucket:bucket_water") minetest.register_alias("bucket_lava", "bucket:bucket_lava") minetest.register_craft({ output = 'bucket:bucket_empty 1', recipe = { {'default:steel_ingot', '', 'default:steel_ingot'}, {'', 'default:steel_ingot', ''}, } }) bucket = {} bucket.liquids = {} local function check_protection(pos, name, text) if minetest.is_protected(pos, name) then minetest.log("action", (name ~= "" and name or "A mod") .. " tried to " .. text .. " at protected position " .. minetest.pos_to_string(pos) .. " with a bucket") minetest.record_protection_violation(pos, name) return true end return false end -- Register a new liquid -- source = name of the source node -- flowing = name of the flowing node -- itemname = name of the new bucket item (or nil if liquid is not takeable) -- inventory_image = texture of the new bucket item (ignored if itemname == nil) -- This function can be called from any mod (that depends on bucket). function bucket.register_liquid(source, flowing, itemname, inventory_image, name) bucket.liquids[source] = { source = source, flowing = flowing, itemname = itemname, } bucket.liquids[flowing] = bucket.liquids[source] if itemname ~= nil then minetest.register_craftitem(itemname, { description = name, inventory_image = inventory_image, stack_max = 1, liquids_pointable = true, groups = {not_in_creative_inventory=1}, on_place = function(itemstack, user, pointed_thing) -- Must be pointing to node if pointed_thing.type ~= "node" then return end local node = minetest.get_node_or_nil(pointed_thing.under) local ndef if node then ndef = minetest.registered_nodes[node.name] end -- Call on_rightclick if the pointed node defines it if ndef and ndef.on_rightclick and user and not user:get_player_control().sneak then return ndef.on_rightclick( pointed_thing.under, node, user, itemstack) or itemstack end local place_liquid = function(pos, node, source, flowing, fullness) if check_protection(pos, user and user:get_player_name() or "", "place "..source) then return end if math.floor(fullness/128) == 1 or not minetest.setting_getbool("liquid_finite") then minetest.add_node(pos, {name=source, param2=fullness}) return elseif node.name == flowing then fullness = fullness + node.param2 elseif node.name == source then fullness = LIQUID_MAX end if fullness >= LIQUID_MAX then minetest.add_node(pos, {name=source, param2=LIQUID_MAX}) else minetest.add_node(pos, {name=flowing, param2=fullness}) end end -- Check if pointing to a buildable node local fullness = tonumber(itemstack:get_metadata()) if not fullness then fullness = LIQUID_MAX end if ndef and ndef.buildable_to then -- buildable; replace the node place_liquid(pointed_thing.under, node, source, flowing, fullness) else -- not buildable to; place the liquid above -- check if the node above can be replaced local node = minetest.get_node_or_nil(pointed_thing.above) if node and minetest.registered_nodes[node.name].buildable_to then place_liquid(pointed_thing.above, node, source, flowing, fullness) else -- do not remove the bucket with the liquid return end end return {name="bucket:bucket_empty"} end }) end end minetest.register_craftitem("bucket:bucket_empty", { description = "Empty Bucket", inventory_image = "bucket.png", stack_max = 1, liquids_pointable = true, on_use = function(itemstack, user, pointed_thing) -- Must be pointing to node if pointed_thing.type ~= "node" then return end -- Check if pointing to a liquid source node = minetest.get_node(pointed_thing.under) liquiddef = bucket.liquids[node.name] if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or (node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then if check_protection(pointed_thing.under, user:get_player_name(), "take ".. node.name) then return end minetest.add_node(pointed_thing.under, {name="air"}) if node.name == liquiddef.source then node.param2 = LIQUID_MAX end return ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)}) end end, }) bucket.register_liquid( "default:water_source", "default:water_flowing", "bucket:bucket_water", "bucket_water.png", "Water Bucket" ) bucket.register_liquid( "default:lava_source", "default:lava_flowing", "bucket:bucket_lava", "bucket_lava.png", "Lava Bucket" ) minetest.register_craft({ type = "fuel", recipe = "bucket:bucket_lava", burntime = 60, replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, })
mit
Ashkanovich/jitsu-king
plugins/banhammer.lua
214
11956
local function pre_process(msg) -- 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 name = user_print_name(msg.from) 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 or is_gbanned(user_id) then -- Check it with redis print('User is banned!') local name = user_print_name(msg.from) 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 local bots_protection = "Yes" local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] 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 name = user_print_name(msg.from) 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' then local data = load_data(_config.moderation.data) 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 name = user_print_name(msg.from) 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 username_id(cb_extra, success, result) local get_cmd = cb_extra.get_cmd local receiver = cb_extra.receiver local chat_id = cb_extra.chat_id local member = cb_extra.member local text = '' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if member_id == our_id then return false end if get_cmd == 'kick' then if is_momod2(member_id, chat_id) then return send_large_msg(receiver, "you can't kick mods/owner/admins") end return kick_user(member_id, chat_id) elseif get_cmd == 'ban' then if is_momod2(member_id, chat_id) then return send_large_msg(receiver, "you can't ban mods/owner/admins") end send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned') return 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') return banall_user(member_id, chat_id) elseif get_cmd == 'unbanall' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned') return unbanall_user(member_id, chat_id) end end end return send_large_msg(receiver, text) end local function run(msg, matches) if matches[1]:lower() == 'id' then if msg.to.type == "user" then return "Bot ID: "..msg.to.id.. "\n\nYour ID: "..msg.from.id end if type(msg.reply_id) ~= "nil" then local name = user_print_name(msg.from) 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 ") return "Group ID for " ..string.gsub(msg.to.print_name, "_", " ").. ":\n\n"..msg.to.id end end local receiver = get_receiver(msg) if matches[1]:lower() == 'kickme' then-- /kickme if msg.to.type == 'chat' then local name = user_print_name(msg.from) 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 nil end if matches[1]:lower() == "banlist" then -- Ban list ! local chat_id = msg.to.id if matches[2] and is_admin(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_admin(msg) then local msgr = get_message(msg.reply_id,ban_by_reply_admins, false) else msgr = get_message(msg.reply_id,ban_by_reply, false) end end if msg.to.type == 'chat' then local user_id = matches[2] local chat_id = msg.to.id if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin(msg) and is_momod2(tonumber(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 name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2]) ban_user(user_id, chat_id) else local member = string.gsub(matches[2], '@', '') local get_cmd = 'ban' local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2]) chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end return end end if matches[1]:lower() == 'unban' then -- /unban if type(msg.reply_id)~="nil" and is_momod(msg) then local msgr = get_message(msg.reply_id,unban_by_reply, false) end if msg.to.type == 'chat' then local user_id = matches[2] local chat_id = msg.to.id local targetuser = matches[2] if string.match(targetuser, '^%d+$') then local user_id = targetuser local hash = 'banned:'..chat_id redis:srem(hash, user_id) local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] unbaned user ".. matches[2]) return 'User '..user_id..' unbanned' else local member = string.gsub(matches[2], '@', '') local get_cmd = 'unban' chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end end end if matches[1]:lower() == 'kick' then if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin(msg) then local msgr = get_message(msg.reply_id,Kick_by_reply_admins, false) else msgr = get_message(msg.reply_id,Kick_by_reply, false) end end if msg.to.type == 'chat' then local user_id = matches[2] local chat_id = msg.to.id if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin(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 name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2]) kick_user(user_id, chat_id) else local member = string.gsub(matches[2], '@', '') local get_cmd = 'kick' local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2]) chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end else return 'This isn\'t a chat group' end end if not is_admin(msg) then return end if matches[1]:lower() == 'banall' then -- Global ban if type(msg.reply_id) ~="nil" and is_admin(msg) then return get_message(msg.reply_id,banall_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id if msg.to.type == 'chat' then local targetuser = matches[2] if string.match(targetuser, '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return false end banall_user(targetuser) return 'User ['..user_id..' ] globally banned' else local member = string.gsub(matches[2], '@', '') local get_cmd = 'banall' chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end end end if matches[1]:lower() == 'unbanall' then -- Global unban local user_id = matches[2] local chat_id = msg.to.id if msg.to.type == 'chat' then if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return false end unbanall_user(user_id) return 'User ['..user_id..' ] removed from global ban list' else local member = string.gsub(matches[2], '@', '') local get_cmd = 'unbanall' chat_info(receiver, username_id, {get_cmd=get_cmd, receiver=receiver, chat_id=msg.to.id, member=member}) end end end if matches[1]:lower() == "gbanlist" then -- Global ban list return banall_list() end end return { patterns = { "^[!/]([Bb]anall) (.*)$", "^[!/]([Bb]anall)$", "^[!/]([Bb]anlist) (.*)$", "^[!/]([Bb]anlist)$", "^[!/]([Gg]banlist)$", "^[!/]([Bb]an) (.*)$", "^[!/]([Kk]ick)$", "^[!/]([Uu]nban) (.*)$", "^[!/]([Uu]nbanall) (.*)$", "^[!/]([Uu]nbanall)$", "^[!/]([Kk]ick) (.*)$", "^[!/]([Kk]ickme)$", "^[!/]([Bb]an)$", "^[!/]([Uu]nban)$", "^[!/]([Ii]d)$", "^!!tgservice (.+)$", }, run = run, pre_process = pre_process }
gpl-2.0
rlcevg/Zero-K
LuaUI/Widgets/gui_highlight_geos.lua
6
2920
function widget:GetInfo() return { name = 'Highlight Geos', desc = 'Highlights geothermal spots when in metal map view', author = 'Niobium, modified by GoogleFrog', version = '1.0', date = 'Mar, 2011', license = 'GNU GPL, v2 or later', layer = 0, enabled = true, -- loaded by default? } end ---------------------------------------------------------------- -- Globals ---------------------------------------------------------------- local geoDisplayList ---------------------------------------------------------------- -- Speedups ---------------------------------------------------------------- local glLineWidth = gl.LineWidth local glDepthTest = gl.DepthTest local glCallList = gl.CallList local spGetMapDrawMode = Spring.GetMapDrawMode local spGetActiveCommand = Spring.GetActiveCommand local spGetGameFrame = Spring.GetGameFrame local geoDefID = UnitDefNames["geo"].id local mapX = Game.mapSizeX local mapZ = Game.mapSizeZ local mapXinv = 1/mapX local mapZinv = 1/mapZ local size = math.max(mapX,mapZ) * 60/4096 ---------------------------------------------------------------- -- Functions ---------------------------------------------------------------- local function PillarVerts(x, y, z) gl.Color(1, 1, 0, 1) gl.Vertex(x, y, z) gl.Color(1, 1, 0, 0) gl.Vertex(x, y + 1000, z) end local geos = {} local function HighlightGeos() local features = Spring.GetAllFeatures() for i = 1, #features do local fID = features[i] if FeatureDefs[Spring.GetFeatureDefID(fID)].geoThermal then local fx, fy, fz = Spring.GetFeaturePosition(fID) gl.BeginEnd(GL.LINE_STRIP, PillarVerts, fx, fy, fz) geos[#geos+1] = {x = fx, z = fz} end end end ---------------------------------------------------------------- -- Callins ---------------------------------------------------------------- local drawGeos = false function widget:Shutdown() if geoDisplayList then gl.DeleteList(geoDisplayList) end end function widget:DrawWorld() local _, cmdID = spGetActiveCommand() local showecoMode = WG.showeco drawGeos = spGetMapDrawMode() == 'metal' or showecoMode or -geoDefID == cmdID or spGetGameFrame() < 1 if drawGeos then if not geoDisplayList then geoDisplayList = gl.CreateList(HighlightGeos) end glLineWidth(20) glDepthTest(true) glCallList(geoDisplayList) glLineWidth(1) end end local function drawMinimapGeos(x,z) gl.Vertex(x - size,0,z - size) gl.Vertex(x + size,0,z + size) gl.Vertex(x + size,0,z - size) gl.Vertex(x - size,0,z + size) end function widget:DrawInMiniMap() if drawGeos then gl.LoadIdentity() gl.Translate(0,1,0) gl.Scale(mapXinv , -mapZinv, 1) gl.Rotate(270,1,0,0) gl.LineWidth(2) gl.Lighting(false) gl.Color(1,1,0,0.7) for i = 1, #geos do local geo = geos[i] gl.BeginEnd(GL.LINES,drawMinimapGeos,geo.x,geo.z) end gl.LineWidth(1.0) gl.Color(1,1,1,1) end end
gpl-2.0
Jennal/cocos2dx-3.2-qt
cocos/scripting/lua-bindings/auto/api/NodeReader.lua
7
1601
-------------------------------- -- @module NodeReader -- @parent_module ccs -------------------------------- -- @function [parent=#NodeReader] setJsonPath -- @param self -- @param #string str -------------------------------- -- @function [parent=#NodeReader] createNode -- @param self -- @param #string str -- @return Node#Node ret (return value: cc.Node) -------------------------------- -- @function [parent=#NodeReader] loadNodeWithFile -- @param self -- @param #string str -- @return Node#Node ret (return value: cc.Node) -------------------------------- -- @function [parent=#NodeReader] purge -- @param self -------------------------------- -- @function [parent=#NodeReader] init -- @param self -------------------------------- -- @function [parent=#NodeReader] loadNodeWithContent -- @param self -- @param #string str -- @return Node#Node ret (return value: cc.Node) -------------------------------- -- @function [parent=#NodeReader] isRecordJsonPath -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- @function [parent=#NodeReader] getJsonPath -- @param self -- @return string#string ret (return value: string) -------------------------------- -- @function [parent=#NodeReader] setRecordJsonPath -- @param self -- @param #bool bool -------------------------------- -- @function [parent=#NodeReader] destroyInstance -- @param self -------------------------------- -- @function [parent=#NodeReader] NodeReader -- @param self return nil
mit
EliHar/Pattern_recognition
torch1/extra/nn/THNN.lua
10
3673
local ffi = require 'ffi' local THNN = {} local generic_THNN_h = require 'nn.THNN_h' -- strip all lines starting with # -- to remove preprocessor directives originally present -- in THNN.h generic_THNN_h = generic_THNN_h:gsub("\n#[^\n]*", "") generic_THNN_h = generic_THNN_h:gsub("^#[^\n]*\n", "") -- THGenerator struct declaration copied from torch7/lib/TH/THRandom.h local base_declarations = [[ typedef void THNNState; typedef struct { unsigned long the_initial_seed; int left; int seeded; unsigned long next; unsigned long state[624]; /* the array for the state vector 624 = _MERSENNE_STATE_N */ double normal_x; double normal_y; double normal_rho; int normal_is_valid; } THGenerator; ]] -- polyfill for LUA 5.1 if not package.searchpath then local sep = package.config:sub(1,1) function package.searchpath(mod, path) mod = mod:gsub('%.', sep) for m in path:gmatch('[^;]+') do local nm = m:gsub('?', mod) local f = io.open(nm, 'r') if f then f:close() return nm end end end end -- load libTHNN THNN.C = ffi.load(package.searchpath('libTHNN', package.cpath)) ffi.cdef(base_declarations) -- expand macros, allow to use original lines from lib/THNN/generic/THNN.h local preprocessed = string.gsub(generic_THNN_h, 'TH_API void THNN_%(([%a%d_]+)%)', 'void THNN_TYPE%1') local replacements = { { ['TYPE'] = 'Double', ['real'] = 'double', ['THTensor'] = 'THDoubleTensor', ['THIndexTensor'] = 'THLongTensor', ['THIntegerTensor'] = 'THIntTensor', ['THIndex_t'] = 'long', ['THInteger_t'] = 'int' }, { ['TYPE'] = 'Float', ['real'] = 'float', ['THTensor'] = 'THFloatTensor', ['THIndexTensor'] = 'THLongTensor', ['THIntegerTensor'] = 'THIntTensor', ['THIndex_t'] = 'long', ['THInteger_t'] = 'int' } } for i=1,#replacements do local r = replacements[i] local s = preprocessed for k,v in pairs(r) do s = string.gsub(s, k, v) end ffi.cdef(s) end THNN.NULL = ffi.NULL or nil function THNN.getState() return ffi.NULL or nil end function THNN.optionalTensor(t) return t and t:cdata() or THNN.NULL end local function extract_function_names(s) local t = {} for n in string.gmatch(s, 'TH_API void THNN_%(([%a%d_]+)%)') do t[#t+1] = n end return t end function THNN.bind(lib, base_names, type_name, state_getter) local ftable = {} local prefix = 'THNN_' .. type_name for i,n in ipairs(base_names) do -- use pcall since some libs might not support all functions (e.g. cunn) local ok,v = pcall(function() return lib[prefix .. n] end) if ok then ftable[n] = function(...) v(state_getter(), ...) end -- implicitely add state else print('not found: ' .. prefix .. n .. v) end end return ftable end -- build function table local function_names = extract_function_names(generic_THNN_h) THNN.kernels = {} THNN.kernels['torch.FloatTensor'] = THNN.bind(THNN.C, function_names, 'Float', THNN.getState) THNN.kernels['torch.DoubleTensor'] = THNN.bind(THNN.C, function_names, 'Double', THNN.getState) torch.getmetatable('torch.FloatTensor').THNN = THNN.kernels['torch.FloatTensor'] torch.getmetatable('torch.DoubleTensor').THNN = THNN.kernels['torch.DoubleTensor'] function THNN.runKernel(f, type, ...) local ftable = THNN.kernels[type] if not ftable then error('Unsupported tensor type: '..type) end local f = ftable[f] if not f then error(string.format("Function '%s' not found for tensor type '%s'.", f, type)) end f(...) end return THNN
mit
cailyoung/CommandPost
src/extensions/cp/apple/finalcutpro/ids/v/10.3.2.lua
1
2616
return { LogicPlugins = { PitchShifter = "Pitch Shifter II", }, CommandEditor = { KeyDetailPanel = "_NS:273", SaveButton = "_NS:50", }, ExportDialog = { BackgroundImage = "_NS:17", }, MediaImporter = { MainPanel = "_NS:39", }, ColorBoard = { ColorBoard = "Color Board", BackButton = "_NS:180", ColorSatExp = "_NS:128", ColorReset = "_NS:288", ColorGlobalPuck = "_NS:278", ColorGlobalPct = "_NS:70", ColorGlobalAngle = "_NS:98", ColorShadowsPuck = "_NS:273", ColorShadowsPct = "_NS:77", ColorShadowsAngle = "_NS:104", ColorMidtonesPuck = "_NS:268", ColorMidtonesPct = "_NS:84", ColorMidtonesAngle = "_NS:110", ColorHighlightsPuck = "_NS:258", ColorHighlightsPct = "_NS:91", ColorHighlightsAngle = "_NS:116", SatReset = "_NS:538", SatGlobalPuck = "_NS:529", SatGlobalPct = "_NS:42", SatShadowsPuck = "_NS:524", SatShadowsPct = "_NS:49", SatMidtonesPuck = "_NS:519", SatMidtonesPct = "_NS:56", SatHighlightsPuck = "_NS:514", SatHighlightsPct = "_NS:63", ExpReset = "_NS:412", ExpGlobalPuck = "_NS:403", ExpGlobalPct = "_NS:9", ExpShadowsPuck = "_NS:398", ExpShadowsPct = "_NS:21", ExpMidtonesPuck = "_NS:393", ExpMidtonesPct = "_NS:28", ExpHighlightsPuck = "_NS:388", ExpHighlightsPct = "_NS:35", }, EffectsBrowser = { Sidebar = "_NS:66", Contents = "_NS:9", }, GeneratorsBrowser = { Sidebar = "_NS:9", }, Inspector = { DetailsPanel = "_NS:112", NothingToInspect = "_NS:53", }, LibrariesBrowser = { Search = "_NS:34", Sidebar = "_NS:9", }, LibrariesFilmstrip = { Content = "_NS:33", }, LibrariesList = { Player = 1, RowIcon = "_NS:11", }, MediaBrowser = { Sidebar = "_NS:9", }, Timeline = { Contents = "_NS:237", }, TimelineAppearance = { Toggle = "_NS:154", ZoomAmount = "_NS:56", }, TimelineToolbar = { ID = "_NS:237", SkimmingGroup = "_NS:178", EffectsGroup = "_NS:165", }, Viewer = { Title = 3, Format = 1, }, ImportPanel = { ID = 4, CreateProxyMedia = 5, CreateOptimizedMedia = 4, MediaLocationGroup = 1, CopyToMediaFolder = 1, LeaveInPlace = 2, }, PlaybackPanel = { ID = 3, CreateMulticamOptimizedMedia = 2, BackgroundRender = 1, }, PreferencesWindow = { Group = "_NS:9" }, }
mit
ViolyS/RayUI_VS
Interface/AddOns/Skada/lib/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua
65
4515
--[[----------------------------------------------------------------------------- DropdownGroup Container Container controlled by a dropdown on the top. -------------------------------------------------------------------------------]] local Type, Version = "DropdownGroup", 21 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 assert, pairs, type = assert, pairs, type -- WoW APIs local CreateFrame = CreateFrame --[[----------------------------------------------------------------------------- Scripts -------------------------------------------------------------------------------]] local function SelectedGroup(self, event, value) local group = self.parentgroup local status = group.status or group.localstatus status.selected = value self.parentgroup:Fire("OnGroupSelected", value) end --[[----------------------------------------------------------------------------- Methods -------------------------------------------------------------------------------]] local methods = { ["OnAcquire"] = function(self) self.dropdown:SetText("") self:SetDropdownWidth(200) self:SetTitle("") end, ["OnRelease"] = function(self) self.dropdown.list = nil self.status = nil for k in pairs(self.localstatus) do self.localstatus[k] = nil end end, ["SetTitle"] = function(self, title) self.titletext:SetText(title) self.dropdown.frame:ClearAllPoints() if title and title ~= "" then self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0) else self.dropdown.frame:SetPoint("TOPLEFT", -1, 0) end end, ["SetGroupList"] = function(self,list,order) self.dropdown:SetList(list,order) end, ["SetStatusTable"] = function(self, status) assert(type(status) == "table") self.status = status end, ["SetGroup"] = function(self,group) self.dropdown:SetValue(group) local status = self.status or self.localstatus status.selected = group self:Fire("OnGroupSelected", group) end, ["OnWidthSet"] = function(self, width) local content = self.content local contentwidth = width - 26 if contentwidth < 0 then contentwidth = 0 end content:SetWidth(contentwidth) content.width = contentwidth end, ["OnHeightSet"] = function(self, height) local content = self.content local contentheight = height - 63 if contentheight < 0 then contentheight = 0 end content:SetHeight(contentheight) content.height = contentheight end, ["LayoutFinished"] = function(self, width, height) self:SetHeight((height or 0) + 63) end, ["SetDropdownWidth"] = function(self, width) self.dropdown:SetWidth(width) end } --[[----------------------------------------------------------------------------- Constructor -------------------------------------------------------------------------------]] local PaneBackdrop = { bgFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 3, right = 3, top = 5, bottom = 3 } } local function Constructor() local frame = CreateFrame("Frame") frame:SetHeight(100) frame:SetWidth(100) frame:SetFrameStrata("FULLSCREEN_DIALOG") local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") titletext:SetPoint("TOPLEFT", 4, -5) titletext:SetPoint("TOPRIGHT", -4, -5) titletext:SetJustifyH("LEFT") titletext:SetHeight(18) local dropdown = AceGUI:Create("Dropdown") dropdown.frame:SetParent(frame) dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2) dropdown:SetCallback("OnValueChanged", SelectedGroup) dropdown.frame:SetPoint("TOPLEFT", -1, 0) dropdown.frame:Show() dropdown:SetLabel("") local border = CreateFrame("Frame", nil, frame) border:SetPoint("TOPLEFT", 0, -26) border:SetPoint("BOTTOMRIGHT", 0, 3) border:SetBackdrop(PaneBackdrop) border:SetBackdropColor(0.1,0.1,0.1,0.5) border:SetBackdropBorderColor(0.4,0.4,0.4) --Container Support local content = CreateFrame("Frame", nil, border) content:SetPoint("TOPLEFT", 10, -10) content:SetPoint("BOTTOMRIGHT", -10, 10) local widget = { frame = frame, localstatus = {}, titletext = titletext, dropdown = dropdown, border = border, content = content, type = Type } for method, func in pairs(methods) do widget[method] = func end dropdown.parentgroup = widget return AceGUI:RegisterAsContainer(widget) end AceGUI:RegisterWidgetType(Type, Constructor, Version)
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nn/MultiMarginCriterion.lua
11
1615
local THNN = require 'nn.THNN' local MultiMarginCriterion, parent = torch.class('nn.MultiMarginCriterion', 'nn.Criterion') function MultiMarginCriterion:__init(p, weights, margin) assert(p == nil or p == 1 or p == 2, 'only p=1 and p=2 supported') self.p = p or 1 self.margin = margin or 1.0 parent.__init(self) self.sizeAverage = true if weights then assert(weights:dim() == 1, "weights input should be 1-D Tensor") self.weights = weights end end function MultiMarginCriterion:updateOutput(input, target) -- backward compatibility if not torch.isTensor(target) then self.target_tensor = self.target_tensor or input.new(1) self.target_tensor[1] = target target = self.target_tensor end self.p = self.p or 1 self.output_tensor = self.output_tensor or input.new(1) input.THNN.MultiMarginCriterion_updateOutput( input:cdata(), target:cdata(), self.output_tensor:cdata(), self.sizeAverage, self.p, THNN.optionalTensor(self.weights), self.margin ) self.output = self.output_tensor[1] return self.output end function MultiMarginCriterion:updateGradInput(input, target) if not torch.isTensor(target) then self.target_tensor = self.target_tensor or input.new(1) self.target_tensor[1] = target target = self.target_tensor end input.THNN.MultiMarginCriterion_updateGradInput( input:cdata(), target:cdata(), self.gradInput:cdata(), self.sizeAverage, self.p, THNN.optionalTensor(self.weights), self.margin ) return self.gradInput end
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nnx/test-all.lua
3
28626
local nnxtest = {} local precision = 1e-5 local mytester -- you can easily test specific units like this: -- th -lnnx -e "nnx.test{'MultiSoftMax'}" -- th -lnnx -e "nnx.test{'SoftMaxTree', 'Balance'}" function nnxtest.SpatialPadding() local fanin = math.random(1,3) local sizex = math.random(4,16) local sizey = math.random(4,16) local pad_l = math.random(0,8) local pad_r = math.random(0,8) local pad_t = math.random(0,8) local pad_b = math.random(0,8) local val = torch.randn(1):squeeze() local module = nn.SpatialPadding(pad_l, pad_r, pad_t, pad_b, val) local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialLinear() local fanin = math.random(1,10) local fanout = math.random(1,10) local in1 = torch.rand(fanin,1,1) local module = nn.SpatialLinear(fanin,fanout) local moduleg = nn.Linear(fanin,fanout) moduleg.weight:copy(module.weight) moduleg.bias:copy(module.bias) local out = module:forward(in1) local ground = moduleg:forward(in1:select(2,1,1):select(2,1,1)) local err = out:dist(ground) mytester:assertlt(err, precision, torch.typename(module) .. ' - forward err ') local fanin = math.random(1,10) local fanout = math.random(1,10) local sizex = math.random(4,16) local sizey = math.random(4,16) local module = nn.SpatialLinear(fanin, fanout) local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local err = nn.Jacobian.testJacobianParameters(module, input, module.weight, module.gradWeight) mytester:assertlt(err, precision, 'error on weight ') local err = nn.Jacobian.testJacobianParameters(module, input, module.bias, module.gradBias) mytester:assertlt(err, precision, 'error on bias ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialMaxPooling() local fanin = math.random(1,4) local osizex = math.random(1,4) local osizey = math.random(1,4) local mx = math.random(2,6) local my = math.random(2,6) local sizex = osizex*mx local sizey = osizey*my local module = nn.SpatialMaxPooling(mx,my) local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end local function template_SpatialReSamplingEx(up, mode) for iTest = 1,3 do local nDims = math.random(2,6) local dims = torch.LongStorage(nDims) for i = 1,nDims do dims[i] = math.random(5,20/nDims) end local xratio, yratio if up then xratio = torch.uniform(1.5, 5) yratio = torch.uniform(1.5, 5) else xratio = torch.uniform(0.41, 0.7) yratio = torch.uniform(0.41, 0.7) end local ydim = math.random(1,nDims-1) local xdim = ydim+1 local owidth_ = math.floor(dims[xdim]*xratio+0.5) local oheight_ = math.floor(dims[ydim]*yratio+0.5) local module = nn.SpatialReSamplingEx({owidth=owidth_, oheight=oheight_, xDim=xdim, yDim = ydim, mode=mode}) local input = torch.rand(dims) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end end function nnxtest.SpatialReSamplingEx1() template_SpatialReSamplingEx(true , 'simple' ) end function nnxtest.SpatialReSamplingEx2() template_SpatialReSamplingEx(false, 'simple' ) end function nnxtest.SpatialReSamplingEx3() template_SpatialReSamplingEx(false, 'average' ) end function nnxtest.SpatialReSamplingEx4() template_SpatialReSamplingEx(true , 'bilinear') end function nnxtest.SpatialReSamplingEx5() template_SpatialReSamplingEx(false, 'bilinear') end function nnxtest.SpatialUpSampling() local fanin = math.random(1,4) local sizex = math.random(1,4) local sizey = math.random(1,4) local mx = math.random(2,6) local my = math.random(2,6) local module = nn.SpatialUpSampling(mx,my) local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialDownSampling() local fanin = math.random(1,4) local sizex = math.random(11,4) local sizey = math.random(11,4) local mx = math.random(2,6) local my = math.random(2,6) local module = nn.SpatialDownSampling(mx,my) local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialReSampling_1() local fanin = math.random(1,4) local sizex = math.random(4,8) local sizey = math.random(4,8) local osizex = math.random(2,12) local osizey = math.random(2,12) local module = nn.SpatialReSampling{owidth=osizex,oheight=osizey} local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') -- test batches (4D input) local batchSize = math.random(4,8) local input2 = torch.rand(batchSize,fanin,sizey,sizex) input2[2]:copy(input) local output = module:forward(input):clone() local output2 = module:forward(input2) mytester:assertTensorEq(output, output2[2], 0.00001, 'SpatialResampling batch forward err') local gradInput = module:backward(input, output):clone() local gradInput2 = module:backward(input2, output2) mytester:assertTensorEq(gradInput, gradInput2[2], 0.00001, 'SpatialResampling batch backward err') -- test rwidth/rheight local input = torch.randn(3,8,10) local module = nn.SpatialReSampling{rwidth=0.5,rheight=0.5} local output = module:forward(input) mytester:assertTableEq(output:size():totable(), {3, 4, 5}, 0.00000001, 'SpatialResampling batch rwidth/rheight err') local input = torch.randn(2,3,8,10) local module = nn.SpatialReSampling{rwidth=0.5,rheight=0.5} local output = module:forward(input) mytester:assertTableEq(output:size():totable(), {2, 3, 4, 5}, 0.00000001, 'SpatialResampling batch rwidth/rheight err') end function nnxtest.SpatialReSampling_2() local fanin = math.random(1,4) local mx = math.random()*4 + 0.1 local my = math.random()*4 + 0.1 local osizex = math.random(4,6) local osizey = math.random(4,6) local sizex = osizex/mx local sizey = osizey/my local module = nn.SpatialReSampling{rwidth=mx,rheight=my} local input = torch.rand(fanin,sizey,sizex) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.HardShrink() local ini = math.random(5,10) local inj = math.random(5,10) local ink = math.random(5,10) local input = torch.Tensor(ink, inj, ini):zero() local module = nn.HardShrink() local err = nn.Jacobian.testJacobian(module, input, 0.1, 2) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input, 0.1, 2) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.Abs() local ini = math.random(5,10) local inj = math.random(5,10) local ink = math.random(5,10) local input = torch.Tensor(ink, inj, ini):zero() local module = nn.Abs() local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.HardShrink() local ini = math.random(5,10) local inj = math.random(5,10) local ink = math.random(5,10) local input = torch.Tensor(ink, inj, ini):zero() local module = nn.HardShrink() local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialConvolution() local from = math.random(1,10) local to = math.random(1,10) local ki = math.random(1,10) local kj = math.random(1,10) local si = math.random(1,1) local sj = math.random(1,1) local ini = math.random(10,20) local inj = math.random(10,20) local module = nn.SpatialConvolution(from, to, ki, kj, si, sj) local input = torch.Tensor(from, inj, ini):zero() local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local err = nn.Jacobian.testJacobianParameters(module, input, module.weight, module.gradWeight) mytester:assertlt(err, precision, 'error on weight ') local err = nn.Jacobian.testJacobianParameters(module, input, module.bias, module.gradBias) mytester:assertlt(err, precision, 'error on bias ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialNormalization_Gaussian2D() local inputSize = math.random(11,20) local kersize = 9 local nbfeatures = math.random(5,10) local kernel = image.gaussian(kersize) local module = nn.SpatialNormalization(nbfeatures,kernel,0.1) local input = torch.rand(nbfeatures,inputSize,inputSize) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') end function nnxtest.SpatialNormalization_Gaussian1D() local inputSize = math.random(14,20) local kersize = 15 local nbfeatures = math.random(5,10) local kernelv = image.gaussian1D(11):resize(11,1) local kernelh = kernelv:t() local module = nn.SpatialNormalization(nbfeatures, {kernelv,kernelh}, 0.1) local input = torch.rand(nbfeatures,inputSize,inputSize) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') end function nnxtest.SpatialNormalization_io() local inputSize = math.random(11,20) local kersize = 7 local nbfeatures = math.random(2,5) local kernel = image.gaussian(kersize) local module = nn.SpatialNormalization(nbfeatures,kernel) local input = torch.rand(nbfeatures,inputSize,inputSize) local ferr, berr = nn.Jacobian.testIO(module,input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end local function template_SpatialFovea(fx,fy,bilinear) local channels = math.random(1,4) local iwidth = 16 local iheight = 16 local module = nn.SpatialFovea{nInputPlane = channels, ratios = {1,2}, preProcessors = {nn.Identity(), nn.Identity()}, processors = {nn.SpatialConvolution(channels,4,3,3), nn.SpatialConvolution(channels,4,3,3)}, bilinear = bilinear, fov = 3, sub = 1} input = torch.rand(channels, iheight, iwidth) module:focus(fx,fy,3) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') module:focus() local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialFovea_focused() template_SpatialFovea(4,7) end function nnxtest.SpatialFovea_unfocused() template_SpatialFovea() end function nnxtest.SpatialFovea_bilinear() template_SpatialFovea(nil,nil,true) end local function template_SpatialPyramid(fx,fy) local channels = math.random(1,4) local iwidth = 16 local iheight = 16 local pyr = nn.SpatialPyramid({1,2},{nn.SpatialConvolution(channels,4,3,3), nn.SpatialConvolution(channels,4,3,3)}, 3, 3, 1, 1) local module = nn.Sequential() module:add(pyr) module:add(nn.JoinTable(1)) input = torch.rand(channels, iheight, iwidth) pyr:focus(fx,fy,3,3) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') pyr:focus() local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialPyramid_focused() template_SpatialPyramid(5,3) end function nnxtest.SpatialPyramid_unfocused() template_SpatialPyramid() end local function template_SpatialGraph(channels, iwidth, iheight, dist, norm) local module = nn.SpatialGraph{normalize=norm, dist=dist} local input = torch.rand(iwidth, iheight, channels) local err = nn.Jacobian.testJacobian(module, input, 0.1, 1) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialGraph_1() template_SpatialGraph(3, 16, 16, 'euclid', true) end function nnxtest.SpatialGraph_2() template_SpatialGraph(16, 4, 4, 'euclid', true) end function nnxtest.SpatialGraph_3() template_SpatialGraph(256, 2, 2, 'euclid', false) end function nnxtest.SpatialGraph_4() template_SpatialGraph(2, 16, 16, 'cosine', false) end function nnxtest.SpatialGraph_5() template_SpatialGraph(64, 3, 3, 'cosine', false) end local function template_SpatialMatching(channels, iwidth, iheight, maxw, maxh, full_output) local module = nn.Sequential() module:add(nn.SplitTable(1)) local parallel = nn.ParallelTable() local seq1 = nn.Sequential() seq1:add(nn.Narrow(2, math.floor(maxh/2), iheight-maxh+1)) seq1:add(nn.Narrow(3, math.floor(maxw/2), iwidth -maxw+1)) parallel:add(seq1) parallel:add(nn.Identity()) module:add(parallel) module:add(nn.SpatialMatching(maxh, maxw, full_output)) local input = torch.rand(2, channels, iheight, iwidth) local err = nn.Jacobian.testJacobian(module, input) mytester:assertlt(err, precision, 'error on state ') local ferr, berr = nn.Jacobian.testIO(module, input) mytester:asserteq(ferr, 0, torch.typename(module) .. ' - i/o forward err ') mytester:asserteq(berr, 0, torch.typename(module) .. ' - i/o backward err ') end function nnxtest.SpatialMatching_1() template_SpatialMatching(4, 16, 16, 5, 5, true) end function nnxtest.SpatialMatching_2() template_SpatialMatching(4, 16, 16, 5, 5, false) end function nnxtest.SpatialMatching_3() template_SpatialMatching(3, 16, 16, 6, 6, true) end function nnxtest.SpatialMatching_4() template_SpatialMatching(3, 20, 20, 4, 4, false) end function nnxtest.SpatialMatching_5() template_SpatialMatching(3, 12, 16, 5, 7, true) end --function nnxtest.SpatialMatching_6() template_SpatialMatching(4, 16, 32, 9, 5, false) end function nnxtest.SoftMaxTree() local input = torch.randn(5,100) local target = torch.IntTensor{20,23,27,10,8} local grad = torch.randn(5) local root_id = 29 local hierarchy={ [29]=torch.IntTensor{30,1,2}, [1]=torch.IntTensor{3,4,5}, [2]=torch.IntTensor{6,7,8}, [3]=torch.IntTensor{9,10,11}, [4]=torch.IntTensor{12,13,14}, [5]=torch.IntTensor{15,16,17}, [6]=torch.IntTensor{18,19,20}, [7]=torch.IntTensor{21,22,23}, [8]=torch.IntTensor{24,25,26,27,28} } local smt = nn.SoftMaxTree(100, hierarchy, root_id) smt:zeroGradParameters() -- compare to the inefficient version for example 3 local concat = nn.ConcatTable() local indices = {3,3,4} local parentIds = {29,2,8} local linears = {} for i,parentId in ipairs(parentIds) do local s = nn.Sequential() local linear = nn.Linear(100,hierarchy[parentId]:size(1)) linears[parentId] = linear local param, grad = smt:getNodeParameters(parentId) local weight, bias = unpack(param) local gradWeight, gradBias = unpack(grad) mytester:assertalmosteq(gradWeight:sum(), 0, 0.000001) mytester:assertalmosteq(gradBias:sum(), 0, 0.000001) linear.weight:set(weight:clone()) linear.bias:set(bias:clone()) s:add(linear) s:add(nn.LogSoftMax()) s:add(nn.Narrow(1,indices[i],1)) concat:add(s) end local mlp = nn.Sequential() mlp:add(concat) mlp:add(nn.CAddTable()) -- will fail without this: smt:zeroGradParameters() mlp:zeroGradParameters() -- forward backward local output = smt:forward{input, target} local mlp_act = mlp:forward(input[3]) local gradInput = smt:backward({input, target}, grad)[1] local mlp_grad = mlp:backward(input[3], grad:narrow(1,3,1)) -- compare mytester:assert(math.abs(output[3] - mlp_act[1]) < 0.00001) mytester:assertTensorEq(gradInput[3], mlp_grad, 0.00001) -- update mytester:assertalmosteq(smt.updates[29], 5, 0.000001) smt:updateParameters(0.1) mlp:updateParameters(0.1) local parentId = 8 local param, grads = smt:getNodeParameters(parentId) local weight, bias = unpack(param) local gradWeight, gradBias = unpack(grads) local linear = linears[parentId] mytester:assertTensorEq(weight, linear.weight, 0.000001) mytester:assertTensorEq(gradWeight, linear.gradWeight, 0.000001) mytester:assertTensorEq(bias, linear.bias, 0.000001) mytester:assertTensorEq(gradBias, linear.gradBias, 0.000001) -- sharedClone if pcall(function() require "dpnn" end) then local smt2 = smt:sharedClone() output = smt:forward{input, target} local output2 = smt2:forward{input, target} mytester:assertTensorEq(output, output2, 0.00001) end -- accUpdate local smt3 = nn.SoftMaxTree(100, hierarchy, root_id, true) smt3:zeroGradParameters() smt3.weight = smt.weight:clone() smt3.bias = smt.bias:clone() local output3 = smt3:forward{input, target} local output = smt3:forward{input, target} local gradInput3 = smt3:backwardUpdate({input, target}, grad, 0.1)[1] local gradInput = smt:backwardUpdate({input, target}, grad, 0.1)[1] mytester:assertTensorEq(output3, output, 0.00001) mytester:assertTensorEq(gradInput3, gradInput, 0.00001) local parentId = 8 local weight3, bias3 = unpack(smt3:getNodeParameters(parentId)) local params = smt:getNodeParameters(parentId) local weight, bias = unpack(params) mytester:assertTensorEq(weight3, weight, 0.000001) mytester:assertTensorEq(bias3, bias, 0.000001) end function nnxtest.TreeNLLCriterion() local input = torch.randn(5,10) local target = torch.ones(5) --all targets are 1 local c = nn.TreeNLLCriterion() -- the targets are actually ignored (SoftMaxTree uses them before TreeNLLCriterion) local err = c:forward(input, target) gradInput = c:backward(input, target) -- compare to ClassNLLCriterion local c2 = nn.ClassNLLCriterion() local err2 = c2:forward(input, target) local gradInput2 = c2:backward(input, target) mytester:asserteq(err2, err, 0.00001) mytester:assertTensorEq(gradInput2:narrow(2,1,1), gradInput, 0.00001) end function nnxtest.CTCCriterion() local criterion = nn.CTCCriterion() local acts = torch.Tensor({{{0,0,0,0,0}}}):transpose(1, 2):contiguous() -- input is seqLength x batch x inputDim local targets = {{1}} local sizes = torch.Tensor({1}) mytester:eq(criterion:updateOutput(acts, targets, sizes), 1.6094379425049, precision, "CTCCriterion.smallTest") local acts = torch.Tensor({{{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,14,15}}}) local targets = {{3,3}} local sizes = torch.Tensor({3}) mytester:eq(criterion:updateOutput(acts, targets, sizes), 7.355742931366, precision, "CTCCriterion.mediumTest") local acts = torch.Tensor({{{-5,-4,-3,-2,-1}, {-10,-9,-8,-7,-6}, {-15,-14,-13,-12,-11}}}):transpose(1, 2):contiguous() local targets = {{2,3}} local sizes = torch.Tensor({3}) mytester:eq(criterion:updateOutput(acts, targets, sizes), 4.9388499259949, precision, "CTCCriterion.mediumNegativeTest") local acts = torch.Tensor({ {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}, {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}}, {{-5,-4,-3,-2,-1},{-10,-9,-8,-7,-6},{-15,-14,-13,-12,-11}} }):transpose(1, 2):contiguous() local targets = {{1},{3,3},{2,3}} local sizes = torch.Tensor({1,3,3}) mytester:eq(criterion:updateOutput(acts, targets, sizes), 13.904030799866 / 3, precision, "CTCCriterion.batchTest") local gradOutputNorm = criterion:updateGradInput(acts, targets, sizes) criterion = nn.CTCCriterion(true) -- batchFirst true, input is batch x seqLength x inputDim local batchFirstActs = torch.Tensor({ {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}, {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}}, {{-5,-4,-3,-2,-1},{-10,-9,-8,-7,-6},{-15,-14,-13,-12,-11}} }) mytester:eq(criterion:updateOutput(batchFirstActs, targets, sizes), 13.904030799866 / 3, precision, "CTCCriterion.batchFirstTest") local gradOutputBatchFirst = criterion:updateGradInput(acts, targets, sizes) mytester:assertTensorEq(gradOutputBatchFirst:transpose(1, 2), gradOutputNorm, precision, "CTCCriterion.gradCheckTest") torch.Tensor({ {0,0,0,0,0},{1,2,3,4,5},{-5,-4,-3,-2,-1}, {0,0,0,0,0},{6,7,8,9,10},{-10,-9,-8,-7,-6}, {0,0,0,0,0},{11,12,13,14,15},{-15,-14,-13,-12,-11}, }) mytester:eq(criterion:updateOutput(batchFirstActs, targets, sizes), 13.904030799866 / 3, precision, "CTCCriterion.batchFirstTest") local gradOutputBatchFirst = criterion:updateGradInput(acts, targets, sizes) mytester:assertTensorEq(gradOutputBatchFirst:transpose(1, 2), gradOutputNorm, precision, "CTCCriterion.2DTensorTest") end local function blur(mean, stdv, size) local range = torch.range(1,size):float() local a = 1/(stdv*math.sqrt(2*math.pi)) local b = -1/(2*stdv*stdv) return range:add(-mean):pow(2):mul(b):exp():mul(a) end function nnxtest.Balance() local inputSize = 7 local batchSize = 3 local nBatch = 1 local input = torch.randn(batchSize, inputSize):mul(0.1):float() for i=1,batchSize do input[i]:add(blur(3, 1, inputSize):float()) end local sm = nn.SoftMax() sm:float() input = sm:forward(input) local gradOutput = torch.randn(batchSize, inputSize):float() local bl = nn.Balance(nBatch) bl:float() local output = bl:forward(input) local p_y = output:sum(1):div(output:sum()) mytester:assert(p_y:std() < 0.02) mytester:assert(math.abs(p_y:sum() - 1) < 0.000001) local gradInput = bl:backward(input, gradOutput) end function nnxtest.MultiSoftMax() local inputSize = 7 local nSoftmax = 5 local batchSize = 3 local input = torch.randn(batchSize, nSoftmax, inputSize) local gradOutput = torch.randn(batchSize, nSoftmax, inputSize) local msm = nn.MultiSoftMax() local output = msm:forward(input) local gradInput = msm:backward(input, gradOutput) mytester:assert(output:isSameSizeAs(input)) mytester:assert(gradOutput:isSameSizeAs(gradInput)) local sm = nn.SoftMax() local input2 = input:view(batchSize*nSoftmax, inputSize) local output2 = sm:forward(input2) local gradInput2 = sm:backward(input2, gradOutput:view(batchSize*nSoftmax, inputSize)) mytester:assertTensorEq(output, output2, 0.000001) mytester:assertTensorEq(gradInput, gradInput2, 0.000001) end function nnxtest.PushPullTable() -- use for targets with SoftMaxTree local input = torch.randn(5,50) local target = torch.IntTensor{20,23,27,10,8} local gradOutput = torch.randn(5) local root_id = 29 local hierarchy={ [29]=torch.IntTensor{30,1,2}, [1]=torch.IntTensor{3,4,5}, [2]=torch.IntTensor{6,7,8}, [3]=torch.IntTensor{9,10,11}, [4]=torch.IntTensor{12,13,14}, [5]=torch.IntTensor{15,16,17}, [6]=torch.IntTensor{18,19,20}, [7]=torch.IntTensor{21,22,23}, [8]=torch.IntTensor{24,25,26,27,28} } local smt = nn.SoftMaxTree(100, hierarchy, root_id) -- create a network where inputs are fed through softmaxtree -- and targets are teleported (pushed then pulled) to softmaxtree local mlp = nn.Sequential() local linear = nn.Linear(50,100) local push = nn.PushTable(2) local pull = push:pull(2) mlp:add(push) mlp:add(nn.SelectTable(1)) mlp:add(linear) mlp:add(pull) mlp:add(smt) -- compare to simpler alternative local mlp2 = nn.Sequential() local para = nn.ParallelTable() para:add(linear:clone()) para:add(nn.Identity()) mlp2:add(para) mlp2:add(smt:clone()) local inputTable = {input, target} local output = mlp:forward(inputTable) local output2 = mlp2:forward(inputTable) local gradInput = mlp:backward(inputTable, gradOutput) local gradInput2 = mlp2:backward(inputTable, gradOutput) mytester:assertTensorEq(output, output2, 0.00001, "push/pull forward error") mytester:assertTensorEq(gradInput[1], gradInput[1], 0.00001, "push/pull backward error") mytester:assertTensorEq(gradInput[2], gradInput[2], 0.00001, "push/pull backward error") -- test multi-pull case local mlp = nn.Sequential() local push = nn.PushTable(2) mlp:add(push) mlp:add(nn.Identity()) mlp:add(push:pull(2)) mlp:add(push:pull(3)) mlp:add(push:pull(1)) -- {1,2} -> {2,1,2,2} local output = mlp:forward(inputTable) mytester:assertTensorEq(output[1], inputTable[2], 0.00001, "push/pull multi-forward error") mytester:assertTensorEq(output[2], inputTable[1], 0.00001, "push/pull multi-forward error") mytester:assertTensorEq(output[3], inputTable[2], 0.00001, "push/pull multi-forward error") mytester:assertTensorEq(output[4], inputTable[2], 0.00001, "push/pull multi-forward error") local gradOutput = {inputTable[2]:clone(), inputTable[1]:clone(), inputTable[2]:clone(), inputTable[2]:clone()} local gradInput = mlp:backward(inputTable, gradOutput) local gradInput2 = inputTable[2]:clone():mul(3) mytester:assertTensorEq(gradInput[1], gradInput[1], 0.00001, "push/pull multi-backward error") mytester:assertTensorEq(gradInput[2], gradInput[2], 0.00001, "push/pull multi-backward error") end function nnx.test(tests) xlua.require('image',true) mytester = torch.Tester() mytester:add(nnxtest) math.randomseed(os.time()) mytester:run(tests) end
mit
notcake/glib
lua/glib/stage1.lua
1
13854
if GLib then return end GLib = {} function GLib.AddCSLuaFile (path) end function GLib.AddCSLuaFolder (folder) end function GLib.AddCSLuaFolderRecursive (folder) end function GLib.AddCSLuaPackFile (path) end function GLib.AddCSLuaPackFolder (folder) end function GLib.AddCSLuaPackFolderRecursive (folder) end function GLib.AddCSLuaPackSystem (systemTableName) end if SERVER then GLib.AddCSLuaFile = AddCSLuaFile function GLib.AddCSLuaFolder (folder, recursive) GLib.Debug ("GLib : Adding " .. folder .. "/* to lua pack...") GLib.EnumerateLuaFolder (folder, "LUA", GLib.AddCSLuaFile, recursive) end function GLib.AddCSLuaFolderRecursive (folder) GLib.Debug ("GLib : Adding " .. folder .. "/* to lua pack...") GLib.EnumerateLuaFolder (folder, "LUA", GLib.AddCSLuaFile, true) end function GLib.AddCSLuaPackFile (path, pathId) GLib.Loader.PackFileManager:Write ( path, GLib.Loader.Read (path, pathId or "LUA") ) end function GLib.AddCSLuaPackFolder (folder, recursive) local startTime = SysTime () GLib.EnumerateLuaFolder (folder, "LUA", GLib.AddCSLuaPackFile, recursive) if SysTime () - startTime > 0.5 then MsgN ("GLib : Adding " .. folder .. "/* to virtual lua pack... done (" .. GLib.Loader.PackFileManager:GetFileCount () .. " total files, " .. GLib.FormatDuration (SysTime () - startTime) .. ")") end GLib.Debug ("GLib : Adding " .. folder .. "/* to virtual lua pack... done (" .. GLib.Loader.PackFileManager:GetFileCount () .. " total files, " .. GLib.FormatDuration (SysTime () - startTime) .. ")") end function GLib.AddCSLuaPackFolderRecursive (folder) local startTime = SysTime () GLib.EnumerateLuaFolder (folder, "LUA", GLib.AddCSLuaPackFile, true) if SysTime () - startTime > 0.5 then MsgN ("GLib : Adding " .. folder .. "/* to virtual lua pack... done (" .. GLib.Loader.PackFileManager:GetFileCount () .. " total files, " .. GLib.FormatDuration (SysTime () - startTime) .. ")") end GLib.Debug ("GLib : Adding " .. folder .. "/* to virtual lua pack... done (" .. GLib.Loader.PackFileManager:GetFileCount () .. " total files, " .. GLib.FormatDuration (SysTime () - startTime) .. ")") end function GLib.AddCSLuaPackSystem (systemTableName) GLib.Loader.PackFileManager:CreatePackFileSystem (systemTableName) GLib.Loader.PackFileManager:SetCurrentPackFileSystem (systemTableName) GLib.Loader.PackFileManager:AddSystemTable (systemTableName) end function GLib.AddReloadCommand (includePath, systemName, systemTableName) includePath = includePath or (systemName .. "/" .. systemName .. ".lua") return reload end end function GLib.AddReloadCommand (includePath, systemName, systemTableName) includePath = includePath or (systemName .. "/" .. systemName .. ".lua") local function reload () local startTime = SysTime () GLib.UnloadSystem (systemTableName) if GLib then GLib.Loader.Include (includePath) else include (includePath) end GLib.Debug (systemName .. "_reload took " .. tostring ((SysTime () - startTime) * 1000) .. " ms.") end if SERVER then concommand.Add (systemName .. "_reload_sv", function (ply, _, arg) if ply and ply:IsValid () and not ply:IsSuperAdmin () then return end reload () end ) concommand.Add (systemName .. "_reload_sh", function (ply, _, arg) if ply and ply:IsValid () and not ply:IsSuperAdmin () then return end reload () for _, ply in ipairs (player.GetAll ()) do ply:ConCommand (systemName .. "_reload") end end ) elseif CLIENT then concommand.Add (systemName .. "_reload", function (ply, _, arg) reload () end ) end return reload end GLib.AddReloadCommand ("glib/glib.lua", "glib", "GLib") function GLib.Debug (message) -- ErrorNoHalt (message .. "\n") end function GLib.EnumerateDelayed (tbl, callback, finishCallback) if not callback then return end local next, tbl, key = pairs (tbl) local value = nil local function timerCallback () local startTime = SysTime () while SysTime () - startTime < 0.001 do key, value = next (tbl, key) if not key and finishCallback then finishCallback () return end callback (key, value) if not key then return end end GLib.CallDelayed (timerCallback) end timerCallback () end function GLib.EnumerateFolder (folder, pathId, callback, recursive) if not callback then return end local files, folders = GLib.Loader.Find (folder .. "/*", pathId) for _, fileName in pairs (files) do callback (folder .. "/" .. fileName, pathId) end if recursive then for _, childFolder in pairs (folders) do if childFolder ~= "." and childFolder ~= ".." then GLib.EnumerateFolder (folder .. "/" .. childFolder, pathId, callback, recursive) end end end end function GLib.EnumerateFolderRecursive (folder, pathId, callback) GLib.EnumerateFolder (folder, pathId, callback, true) end function GLib.EnumerateLuaFolder (folder, pathId, callback, recursive) GLib.EnumerateFolder (folder, pathId or "LUA", function (path, pathId) if path:sub (-4):lower () ~= ".lua" then return end callback (path, pathId) end, recursive ) end function GLib.EnumerateLuaFolderRecursive (folder, pathId, callback) GLib.EnumerateLuaFolder (folder, pathId, callback, true) end function GLib.Error (message) message = tostring (message) local fullMessage = " \n\t" .. message .. "\n\t\t" .. string.gsub (GLib.StackTrace (nil, 1), "\n", "\n\t\t") .. "\n" ErrorNoHalt (fullMessage) end function GLib.FindUpValue (func, name) local i = 1 local a, b = true, nil while a ~= nil do a, b = debug.getupvalue (func, i) if a == name then return b end i = i + 1 end end local string_format = string.format local timeUnits = { "ns", "µs", "ms", "s", "ks", "Ms", "Gs", "Ts", "Ps", "Es", "Zs", "Ys" } function GLib.FormatDuration (duration) duration = duration * 1000000000 local unitIndex = 1 while duration >= 1000 and timeUnits [unitIndex + 1] do duration = duration / 1000 unitIndex = unitIndex + 1 end return string_format ("%.2f %s", duration, timeUnits [unitIndex]) end local sizeUnits = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" } function GLib.FormatFileSize (size) local unitIndex = 1 while size >= 1024 and sizeUnits [unitIndex + 1] do size = size / 1024 unitIndex = unitIndex + 1 end return string_format ("%.2f %s", size, sizeUnits [unitIndex]) end function GLib.GetStackDepth () local i = 0 while debug.getinfo (i) do i = i + 1 end return i end function GLib.Initialize (systemName, systemTable) if not systemTable then GLib.Error ("GLib.Initialize : Called incorrectly.") end setmetatable (systemTable, getmetatable (systemTable) or {}) if systemTable ~= GLib then getmetatable (systemTable).__index = GLib for k, v in pairs (GLib) do if type (v) == "table" then -- Object static tables local metatable = debug.getmetatable (v) local ictorInvoker = metatable and metatable.__call or nil systemTable [k] = {} if v.__static then systemTable [k].__static = true end setmetatable (systemTable [k], { __index = v, __call = ictorInvoker } ) end end end GLib.EventProvider (systemTable) systemTable:AddEventListener ("Unloaded", "GLib.Unloader", function () if not istable (ULib) then hook.Remove ("ShutDown", tostring (systemName)) end end ) hook.Add ("ShutDown", tostring (systemName), function () GLib.Debug ("Unloading " .. systemName .. "...") systemTable:DispatchEvent ("Unloaded") end ) GLib.CallDelayed ( function () hook.Call ("GLibSystemLoaded", GAMEMODE or GM, tostring (systemName)) hook.Call (tostring (systemName) .. "Loaded", GAMEMODE or GM) end ) end function GLib.IncludeDirectory (folder, recursive) local included = {} local paths = { "LUA" } if SERVER then paths [#paths + 1] = "LSV" end if CLIENT and GetConVar ("sv_allowcslua"):GetBool () then paths [#paths + 1] = "LCL" end local folderListList = recursive and {} or nil for _, path in ipairs (paths) do local files, folders = GLib.Loader.Find (folder .. "/*", path) if recursive then folderListList [#folderListList + 1] = folders end for _, file in ipairs (files) do if string.lower (string.sub (file, -4)) == ".lua" and not included [string.lower (file)] then GLib.Loader.Include (folder .. "/" .. file) included [string.lower (file)] = true end end end if recursive then for _, folders in ipairs (folderListList) do for _, childFolder in ipairs (folders) do if childFolder ~= "." and childFolder ~= ".." and not included [string.lower (childFolder)] then GLib.IncludeDirectory (folder .. "/" .. childFolder, recursive) included [string.lower (childFolder)] = true end end end end end function GLib.InvertTable (tbl, out) out = out or {} local keys = {} for key, _ in pairs (tbl) do keys [#keys + 1] = key end for i = 1, #keys do out [tbl [keys [i]]] = keys [i] end return out end function GLib.NullCallback () end function GLib.PrettifyString (str) local out = "" for i = 1, #str do local char = string.sub (str, i, i) local byte = string.byte (char) if byte < 32 or byte >= 127 then out = out .. string.format ("\\x%02x", byte) else if char == "\\" then char = "\\\\" elseif char == "\r" then char = "\\r" elseif char == "\n" then char = "\\n" elseif char == "\t" then char = "\\t" elseif char == "\"" then char = "\\\"" elseif char == "\'" then char = "\\\'" end out = out .. char end end return out end function GLib.PrintStackTrace () ErrorNoHalt (GLib.StackTrace (nil, 2)) end function GLib.StackTrace (levels, frameOffset) local stringBuilder = GLib.StringBuilder () local frameOffset = frameOffset or 1 local exit = false local i = 0 local shown = 0 while not exit do local t = debug.getinfo (i) if not t or shown == levels then exit = true else local name = t.name local src = t.short_src src = src or "<unknown>" if i >= frameOffset then shown = shown + 1 if name then stringBuilder:Append (string.format ("%2d", i) .. ": " .. name .. " (" .. src .. ": " .. tostring (t.currentline) .. ")\n") else if src and t.currentline then stringBuilder:Append (string.format ("%2d", i) .. ": (" .. src .. ": " .. tostring (t.currentline) .. ")\n") else stringBuilder:Append (string.format ("%2d", i) .. ":\n") PrintTable (t) end end end end i = i + 1 end return stringBuilder:ToString () end function GLib.UnloadSystem (systemTableName) if not systemTableName then return end if type (_G [systemTableName]) == "table" and type (_G [systemTableName].DispatchEvent) == "function" then _G [systemTableName]:DispatchEvent ("Unloaded") end _G [systemTableName] = nil hook.Call ("GLibSystemUnloaded", GAMEMODE or GM, systemTableName) hook.Call (systemTableName .. "Unloaded", GAMEMODE or GM) end if CLIENT then function GLib.WaitForLocalPlayer (callback) if not LocalPlayer or not LocalPlayer () or not LocalPlayer ():IsValid () then GLib.CallDelayed ( function () GLib.WaitForLocalPlayer (callback) end ) return end callback () end end function GLib.WeakTable () local tbl = {} setmetatable (tbl, { __mode = "kv" }) return tbl end function GLib.WeakKeyTable () local tbl = {} setmetatable (tbl, { __mode = "k" }) return tbl end function GLib.WeakValueTable () local tbl = {} setmetatable (tbl, { __mode = "v" }) return tbl end -- GLib.Initialize uses this code include ("oop/enum.lua") include ("oop/oop.lua") include ("timers.lua") include ("events/eventprovider.lua") GLib.Initialize ("GLib", GLib) -- Now load the rest include ("userid.lua") include ("stringbuilder.lua") include ("bitconverter.lua") include ("io/inbuffer.lua") include ("io/outbuffer.lua") include ("io/stringinbuffer.lua") include ("io/stringoutbuffer.lua") include ("transfers/transfers.lua") include ("transfers/inboundtransfer.lua") include ("transfers/outboundtransfer.lua") include ("resources/resources.lua") include ("resources/resource.lua") include ("resources/resourcestate.lua") include ("resources/resourcecache.lua") include ("loader/loader.lua") include ("loader/packfilesystem.lua") include ("loader/packfilemanager.lua") include ("loader/commands.lua") -- This has to be done after the Loader library is loaded, -- since GLib.EnumerateFolder calls GLib.Loader.Find. GLib.AddCSLuaFile ("glib/glib.lua") GLib.AddCSLuaFile ("glib/stage1.lua") GLib.AddCSLuaFile ("glib/oop/enum.lua") GLib.AddCSLuaFile ("glib/oop/oop.lua") GLib.AddCSLuaFile ("glib/timers.lua") GLib.AddCSLuaFile ("glib/userid.lua") GLib.AddCSLuaFile ("glib/events/eventprovider.lua") GLib.AddCSLuaFile ("glib/stringbuilder.lua") GLib.AddCSLuaFile ("glib/bitconverter.lua") GLib.AddCSLuaFile ("glib/io/inbuffer.lua") GLib.AddCSLuaFile ("glib/io/outbuffer.lua") GLib.AddCSLuaFile ("glib/io/stringinbuffer.lua") GLib.AddCSLuaFile ("glib/io/stringoutbuffer.lua") GLib.AddCSLuaFolderRecursive ("glib/transfers") GLib.AddCSLuaFolderRecursive ("glib/resources") GLib.AddCSLuaFolderRecursive ("glib/loader") GLib.AddCSLuaFile ("glib/addons.lua") -- Stage 2 GLib.AddCSLuaPackSystem ("GLib") GLib.AddCSLuaPackFile ("autorun/glib.lua") GLib.AddCSLuaPackFolderRecursive ("glib")
gpl-3.0
mohammmadmtf/teleagent
plugins/inrealm.lua
850
25085
-- data saved to moderation.json -- check moderation plugin do local function create_group(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function create_realm(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function get_group_type(msg) local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if not data[tostring(msg.to.id)]['group_type'] then return 'No group type available.' end local group_type = data[tostring(msg.to.id)]['group_type'] return group_type else return 'Chat type not found.' end end local function callbackres(extra, success, result) --vardump(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 set_description(msg, data, target, about) if not is_admin(msg) then return "For admins 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 set_rules(msg, data, target) if not is_admin(msg) then return "For admins 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 -- lock/unlock group name. bot automatically change group name when locked local function lock_group_name(msg, data, target) if not is_admin(msg) then return "For admins 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_name(msg, data, target) if not is_admin(msg) then return "For admins 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 --lock/unlock group member. bot automatically kick new added user when locked local function lock_group_member(msg, data, target) if not is_admin(msg) then return "For admins 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_member(msg, data, target) if not is_admin(msg) then return "For admins 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 --lock/unlock group photo. bot automatically keep group photo when locked local function lock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'yes' then return 'Group photo is already locked' else data[tostring(target)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) end return 'Please send me the group photo now' end local function unlock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins 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 lock_group_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" 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_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" 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 -- show group settings local function show_group_settings(msg, data, target) local data = load_data(_config.moderation.data, data) if not is_admin(msg) then return "For admins only!" 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 return text end local function returnids(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end send_large_msg(receiver, text) local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() end local function returnidsfile(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false) end local function admin_promote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if data[tostring(admins)][tostring(admin_id)] then return admin_name..' is already an admin.' end data[tostring(admins)][tostring(admin_id)] = admin_id save_data(_config.moderation.data, data) return admin_id..' has been promoted as admin.' end local function admin_demote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if not data[tostring(admins)][tostring(admin_id)] then return admin_id..' is not an admin.' end data[tostring(admins)][tostring(admin_id)] = nil save_data(_config.moderation.data, data) return admin_id..' has been demoted from admin.' end local function admin_list(msg) local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end local message = 'List for Realm admins:\n' for k,v in pairs(data[tostring(admins)]) do message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n' end return message end local function groups_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of groups:\n' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['set_owner'] then group_owner = tostring(data[tostring(v)]['set_owner']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/groups.txt", "w") file:write(message) file:flush() file:close() return message end local function realms_list(msg) local data = load_data(_config.moderation.data) local realms = 'realms' if not data[tostring(realms)] then return 'No Realms at the moment' end local message = 'List of Realms:\n' for k,v in pairs(data[tostring(realms)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['admins_in'] then group_owner = tostring(data[tostring(v)]['admins_in']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/realms.txt", "w") file:write(message) file:flush() file:close() return message end local function admin_user_promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already as admin.') end data['admins'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.') end local function admin_user_demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if not data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not an admin.') end data['admins'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Admin '..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 == 'addadmin' then return admin_user_promote(receiver, member_username, member_id) elseif mod_cmd == 'removeadmin' then return admin_user_demote(receiver, member_username, member_id) end end end send_large_msg(receiver, text) end local function set_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'yes' then return 'Log group is already set' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes' save_data(_config.moderation.data, data) return 'Log group has been set' end end local function unset_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'no' then return 'Log group is already disabled' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no' save_data(_config.moderation.data, data) return 'log group has been disabled' end end local function help() local help_text = tostring(_config.help_text_realm) return help_text end function run(msg, matches) --vardump(msg) local name_log = user_print_name(msg.from) if matches[1] == 'log' and is_owner(msg) then savelog(msg.to.id, "log file created by owner") send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false) end if matches[1] == 'who' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ") local receiver = get_receiver(msg) chat_info(receiver, returnidsfile, {receiver=receiver}) end if matches[1] == 'wholist' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file") local receiver = get_receiver(msg) chat_info(receiver, returnids, {receiver=receiver}) end if matches[1] == 'creategroup' and matches[2] then group_name = matches[2] group_type = 'group' return create_group(msg) end if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then return --Do nothing end if matches[1] == 'createrealm' and matches[2] then group_name = matches[2] group_type = 'realm' return create_realm(msg) end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if matches[2] then if data[tostring(matches[2])] then local settings = data[tostring(matches[2])]['settings'] if matches[1] == 'setabout' and matches[2] then local target = matches[2] local about = matches[3] return set_description(msg, data, target, about) end if matches[1] == 'setrules' then rules = matches[3] local target = matches[2] return set_rules(msg, data, target) end if matches[1] == 'lock' then --group lock * local target = matches[2] if matches[3] == 'name' then return lock_group_name(msg, data, target) end if matches[3] == 'member' then return lock_group_member(msg, data, target) end if matches[3] == 'photo' then return lock_group_photo(msg, data, target) end if matches[3] == 'flood' then return lock_group_flood(msg, data, target) end end if matches[1] == 'unlock' then --group unlock * local target = matches[2] if matches[3] == 'name' then return unlock_group_name(msg, data, target) end if matches[3] == 'member' then return unlock_group_member(msg, data, target) end if matches[3] == 'photo' then return unlock_group_photo(msg, data, target) end if matches[3] == 'flood' then return unlock_group_flood(msg, data, target) end end if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then local target = matches[2] return show_group_settings(msg, data, target) end if matches[1] == 'setname' and is_realm(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, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setgpname' and is_admin(msg) then local new_name = string.gsub(matches[3], '_', ' ') data[tostring(matches[2])]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(matches[2])]['settings']['set_name'] local to_rename = 'chat#id'..matches[2] 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 end end if matches[1] == 'help' and is_realm(msg) then savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'set' then if matches[2] == 'loggroup' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group") return set_log_group(msg) end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return modrem(msg), print("Closing Group: "..receiver), chat_info(receiver, killchat, {receiver=receiver}) else return 'Error: Group '..matches[3]..' not found' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return realmrem(msg), print("Closing realm: "..receiver), chat_info(receiver, killrealm, {receiver=receiver}) else return 'Error: Realm '..matches[3]..' not found' end end if matches[1] == 'chat_add_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 if not is_admin(msg) then chat_del_user(chat, user, ok_cb, true) end end if matches[1] == 'addadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been promoted as admin") return admin_promote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "addadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'removeadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been demoted") return admin_demote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "removeadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'type'then local group_type = get_group_type(msg) return group_type end if matches[1] == 'list' and matches[2] == 'admins' then return admin_list(msg) end if matches[1] == 'list' and matches[2] == 'groups' then if msg.to.type == 'chat' then groups_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) elseif msg.to.type == 'user' then groups_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) end end if matches[1] == 'list' and matches[2] == 'realms' then if msg.to.type == 'chat' then realms_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) elseif msg.to.type == 'user' then realms_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) end 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 return { patterns = { "^[!/](creategroup) (.*)$", "^[!/](createrealm) (.*)$", "^[!/](setabout) (%d+) (.*)$", "^[!/](setrules) (%d+) (.*)$", "^[!/](setname) (.*)$", "^[!/](setgpname) (%d+) (.*)$", "^[!/](setname) (%d+) (.*)$", "^[!/](lock) (%d+) (.*)$", "^[!/](unlock) (%d+) (.*)$", "^[!/](setting) (%d+)$", "^[!/](wholist)$", "^[!/](who)$", "^[!/](type)$", "^[!/](kill) (chat) (%d+)$", "^[!/](kill) (realm) (%d+)$", "^[!/](addadmin) (.*)$", -- sudoers only "^[!/](removeadmin) (.*)$", -- sudoers only "^[!/](list) (.*)$", "^[!/](log)$", "^[!/](help)$", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
EliHar/Pattern_recognition
torch1/extra/penlight/tests/test-seq.lua
8
1439
local input = require 'pl.input' local seq = require 'pl.seq' local asserteq = require('pl.test').asserteq local utils = require 'pl.utils' local stringio = require 'pl.stringio' local unpack = utils.unpack local L = utils.string_lambda local S = seq.list local C = seq.copy local C2 = seq.copy2 asserteq (seq.sum(input.numbers '10 20 30 40 50'),150) local x,y = unpack(C(input.numbers('10 20'))) assert (x == 10 and y == 20) local test = {{1,10},{2,20},{3,30}} asserteq(C2(ipairs{10,20,30}),test) local res = C2(input.fields({1,2},',','1,10\n2,20\n3,30\n')) asserteq(res,test) asserteq( seq.copy(seq.filter(seq.list{10,20,5,15},seq.greater_than(10))), {20,15} ) asserteq(seq.reduce('-',{1,2,3,4,5}),-13) asserteq(seq.count(S{10,20,30,40},L'|x| x > 20'), 2) asserteq(C2(seq.zip({1,2,3},{10,20,30})),test) asserteq(C(seq.splice({10,20},{30,40})),{10,20,30,40}) asserteq(C(seq.map(L'#_',{'one','tw'})),{3,2}) --for l1,l2 in seq.last{10,20,30} do print(l1,l2) end asserteq(C2(seq.last{10,20,30}),{{20,10},{30,20}} ) asserteq( seq{10,20,30}:map(L'_+1'):copy(), {11,21,31} ) asserteq( seq{'one','two'}:upper():copy(), {'ONE','TWO'} ) asserteq( C(seq.unique(seq.list{1,2,3,2,1})), {1,2,3} ) local f = stringio.open '1 2 3 4' -- seq.lines may take format specifiers if using Lua 5.2, or a 5.2-compatible -- file object like that returned by stringio. asserteq( seq.lines(f,'*n'):copy(), {1,2,3,4} )
mit
rlcevg/Zero-K
scripts/factoryplane.lua
16
4552
include "constants.lua" local spGetUnitTeam = Spring.GetUnitTeam --pieces local base = piece "base" local bay = piece "bay" local narm1 = piece "narm1" local nano1 = piece "nano1" local emit1 = piece "emit1" local arm1b = piece "arm1b" local arm1 = piece "arm1" local arm1top = piece "arm1top" local arm1bot = piece "arm1bot" local pow1 = piece "pow1" local pow2 = piece "pow2" local plate = piece "plate" local nano2 = piece "nano2" local emit2 = piece "emit2" local door1 = piece "door1" local door2 = piece "door2" local fuelpad = piece "fuelpad" local padbase = piece "padbase" local pad1 = piece "pad1" local pad2 = piece "pad2" local pad3 = piece "pad3" local build = piece "build" local land = piece "land" --local vars local nanoPieces = {emit1,emit2} local nanoIdx = 1 local smokePiece = { piece "bay", piece "pad1", piece "fuelpad" } --opening animation local function Open() Signal(2) --kill the closing animation if it is in process --SetSignalMask(1) --set the signal to kill the opening animation Move(bay, 1, -18, 15) Turn(narm1, 1, 1.85, 0.75) Turn(nano1, 1, -1.309, 0.35) Turn(door1, 2, -0.611, 0.35) Sleep(600) Move(arm1b, 1, -11, 5) Turn(pow1, 3, -1.571, 0.8) WaitForTurn(door1, 2) Turn(door2, 2, 1.571, 0.9) Turn(arm1, 1, 1.3, 0.35) Turn(arm1top, 1, -0.873, 0.4) Turn(arm1bot, 1, 1.31, 0.5) Sleep(200) Turn(pow2, 1, 1.571, 1) WaitForTurn(door2, 2) Turn(narm1, 1, 1.466, 0.15) Move(plate, 3, 8.47, 3.2) Turn(door1, 2, 0, 0.15) Turn(nano2, 2, 0.698, 0.35) Sleep(500) Turn(arm1, 1, 0.524, 0.2) Sleep(150) -- SetUnitValue(COB.YARD_OPEN, 1) --Tobi said its not necessary SetUnitValue(COB.BUGGER_OFF, 1) SetUnitValue(COB.INBUILDSTANCE, 1) end --closing animation of the factory local function Close() Signal(1) --kill the opening animation if it is in process SetSignalMask(2) --set the signal to kill the closing animation -- SetUnitValue(COB.YARD_OPEN, 0) SetUnitValue(COB.BUGGER_OFF, 0) SetUnitValue(COB.INBUILDSTANCE, 0) Turn(narm1, 1, 1.85, 0.25) Sleep(800) Turn(arm1, 1, 1, 0.45) Move(plate, 3, 0, 3.2) Turn(door1, 2, -0.611, 0.15) Turn(nano2, 2, 0, 0.35) WaitForMove(plate, 3) Turn(arm1top, 1, 0, 0.4) Turn(arm1bot, 1, 0, 0.5) Turn(pow2, 1, 0, 1) Sleep(200) Turn(arm1, 1, 0, 0.3) Turn(door2, 2, 0, 0.9) WaitForTurn(door2, 2) Move(arm1b, 1, 0, 5) Turn(pow1, 3, 0, 1) Sleep(600) Turn(narm1, 1, 0, 0.75) Turn(nano1, 1, 0, 0.35) Turn(door1, 2, 0, 0.35) WaitForTurn(door1, 2) Move(bay, 1, 0, 11) WaitForMove(bay,1) end function padchange() while true do Sleep(1200) Hide(pad1) Show(pad2) Sleep(1200) Hide(pad2) Show(pad3) Sleep(1200) Hide(pad3) Show(pad2) Sleep(1200) Hide(pad2) Show(pad1) end end function script.Create() StartThread(SmokeUnit, smokePiece) Spring.SetUnitNanoPieces(unitID, nanoPieces) local buildprogress = select(5, Spring.GetUnitHealth(unitID)) while buildprogress < 1 do Sleep(250) buildprogress = select(5, Spring.GetUnitHealth(unitID)) end StartThread(padchange) end function script.QueryBuildInfo() return build end function script.QueryNanoPiece() if (nanoIdx == 2) then nanoIdx = 1 else nanoIdx = nanoIdx + 1 end local nano = nanoPieces[nanoIdx] --// send to LUPS GG.LUPS.QueryNanoPiece(unitID,unitDefID,spGetUnitTeam(unitID),nano) return nano end function script.QueryLandingPads() return { land } end function script.Activate () StartThread(Open) --animation needs its own thread because Sleep and WaitForTurn will not work otherwise end function script.Deactivate () StartThread(Close) end --death and wrecks function script.Killed(recentDamage, maxHealth) local severity = recentDamage / maxHealth if (severity <= .25) then Explode(pad1, SFX.EXPLODE) Explode(fuelpad, SFX.EXPLODE_ON_HIT) Explode(nano1, SFX.EXPLODE_ON_HIT) Explode(nano2, SFX.EXPLODE_ON_HIT) Explode(door1, SFX.EXPLODE_ON_HIT) Explode(door2, SFX.EXPLODE_ON_HIT) return 1 -- corpsetype elseif (severity <= .5) then Explode(base, SFX.SHATTER) Explode(pad1, SFX.EXPLODE) Explode(fuelpad, SFX.EXPLODE_ON_HIT) Explode(nano1, SFX.EXPLODE_ON_HIT) Explode(nano2, SFX.EXPLODE_ON_HIT) Explode(door1, SFX.EXPLODE_ON_HIT) Explode(door2, SFX.EXPLODE_ON_HIT) return 1 -- corpsetype else Explode(base, SFX.SHATTER) Explode(bay, SFX.SHATTER) Explode(door1, SFX.SHATTER) Explode(door2, SFX.SHATTER) Explode(fuelpad, SFX.SHATTER) Explode(pad1, SFX.EXPLODE) Explode(nano1, SFX.EXPLODE_ON_HIT) Explode(nano2, SFX.EXPLODE_ON_HIT) return 2 -- corpsetype end end
gpl-2.0
rlcevg/Zero-K
LuaUI/Widgets/map_draw_blocker.lua
17
9188
function widget:GetInfo() return { name = "Map Draw Blocker", desc = "blocks map draws from spamers", author = "SirMaverick", date = "2010", license = "GNU GPL, v2 or later", layer = 0, enabled = false, } end local GetPlayerList = Spring.GetPlayerList local GetPlayerInfo = Spring.GetPlayerInfo -- see rts/System/BaseNetProtocol.h for message ids local traffic = { NETMSG_MAPDRAW = { id = 31, playerdata = {}, }, } -- drawCmds[playerid] = {counters = {point = {}, line = {}, erase = {}}, labels = {...}, blocked = false} local drawCmds = {} local drawTypes = { "point", "line", "erase" } local validTypes = {} local counterNum = 10 local currentCounter = 1 local timeFrame = 1 local timerCmd = 0 local blocklimit = 5 local action_unblock = "mapdrawunblock" local action_block = "mapdrawblock" local action_gui = "mapdrawgui" local action_list = "mapdrawlistblocked" local Chili local Button local Control local Label local Colorbars local Checkbox local Trackbar local Window local ScrollPanel local StackPanel local Grid local TextBox local Image local screen0 -- traffic stats local window0 = nil -- MapDrawCmd local window1 = nil local timer = 0 -- helper functions local function SetupDrawCounter(p) drawCmds[p] = {} drawCmds[p].blocked = false drawCmds[p].counters = {} drawCmds[p].labels = {} for j,s in ipairs(drawTypes) do drawCmds[p].counters[s] = {} for k=1,counterNum do drawCmds[p].counters[s][k] = 0 end end end local function SetupDrawCounters() -- direct mapping for j,s in ipairs(drawTypes) do validTypes[s] = true end local playerlist = GetPlayerList() -- player ids start at 0 for i,p in ipairs(playerlist) do SetupDrawCounter(p) end end local function ClearCurrentBuffer() local playerlist = GetPlayerList() -- player ids start at 0 for i,p in ipairs(playerlist) do for j,s in ipairs(drawTypes) do -- FIXME/TODO no info for new players, needs engine change? -- even PlayerChanged is not called before you see player in GetPlayerList() if not drawCmds[p] then SetupDrawCounter(p) end drawCmds[p].counters[s][currentCounter] = 0 end end end local function UpdateLabels() --if window1 then local playerlist = GetPlayerList() for i,p in ipairs(playerlist) do for j,s in ipairs(drawTypes) do local k = currentCounter local sum = 0 for i=1,counterNum do sum = sum + drawCmds[p].counters[s][i] --[[a = a - 1 a = (a-1)%counterNum a = a + 1]] end sum = sum / counterNum / timeFrame if window1 then drawCmds[p].labels[s]:SetCaption(string.format("%.2f", tostring(sum))) end if sum > blocklimit and s ~= "erase" and not drawCmds[p].blocked then drawCmds[p].blocked = true local name,_,_,teamid = Spring.GetPlayerInfo(p) Spring.Echo("Blocking map draw for " .. name .. "(" .. p .. ")") end end end --end end local function CreateDrawCmdWindow() local playerlist = GetPlayerList() window1 = Window:New{ x = 500, y = 300, minWidth = 500, minHeight = 150, width = 500, height = 100 + 50*(#playerlist), caption = "user map draw activity", parent = screen0, } local contentPane = Chili.StackPanel:New({ parent = window1, width = "100%", height = "100%", itemMargin = {5, 5, 5, 5}, }) for p, data in pairs(drawCmds) do local name,_,_,teamid = Spring.GetPlayerInfo(p) local counters = data.counters local subpane = Chili.LayoutPanel:New({ parent = contentPane, width = "100%", --height = 20, rows = 1, horientation = "horizontal", }) local label = Chili.Label:New{ parent = subpane, caption = name, width = 200, autosize = false, fontsize = 12, font = {color = {Spring.GetTeamColor(teamid)},} } for i,s in ipairs(drawTypes) do local labelc = Chili.Label:New{ parent = subpane, caption = "0", width = 50, autosize = false, fontsize = 12, } data.labels[s] = labelc end end end local function CreateTrafficWindow() local playerlist = GetPlayerList() window0 = Window:New{ x = 500, y = 300, minWidth = 400, minHeight = 150, width = 400, height = 100 + 50*(#playerlist), caption = "map draw statistic", parent = screen0, } local contentPane = Chili.StackPanel:New({ parent = window1, width = "100%", height = "100%", itemMargin = {5, 5, 5, 5}, }) for msg, data in pairs(traffic) do local id = data.id for i,p in ipairs(playerlist) do local name,_,_,teamid = Spring.GetPlayerInfo(p) data.playerdata[p] = {} data.playerdata[p]["counters"] = {} local counters = data.playerdata[p].counters local subpane = Chili.LayoutPanel:New({ parent = contentPane, width = "100%", height = 50, rows = 1, horientation = "horizontal", }) local label = Chili.Label:New{ parent = subpane, caption = name, clientWidth = 200, autosize = false, fontsize = 12, font = {color = {Spring.GetTeamColor(teamid)},} } -- counter setup for i=1,5 do counters[i] = Spring.GetPlayerTraffic(p, data.id) end local labelc = Chili.Label:New{ parent = subpane, caption = "0.00 B/s", --width = 50, autosize = false, fontsize = 12, } data.playerdata[p]["label"] = labelc end end end local function Output() if window0 then -- update traffic window local playerlist = GetPlayerList() for i,p in ipairs(playerlist) do local name,_,_,teamid = Spring.GetPlayerInfo(p) if name then for name, data in pairs(traffic) do local ret = Spring.GetPlayerTraffic(p, data.id) if ret > 0 then -- update counters local counters = data.playerdata[p].counters for i=5,2,-1 do counters[i] = counters[i-1] end counters[1] = ret local label = data.playerdata[p].label local sum = counters[1] - counters[5] label:SetCaption(string.format("%.2f B/s", tostring(sum/5))) end end end end end -- window0 end function ActionUnBlock(_,_,parms) local p = tonumber(parms[1]) if not p then return end local name = Spring.GetPlayerInfo(p) if name then drawCmds[p].blocked = false Spring.Echo("unblocking map draw for " .. name) end end function ActionBlock(_,_,parms) local p = tonumber(parms[1]) if not p then return end local name = Spring.GetPlayerInfo(p) if name then drawCmds[p].blocked = true Spring.Echo("blocking map draw for " .. name) end end function ActionGUI() if window1 then window1:Dispose() window1 = nil else CreateDrawCmdWindow() end end function ActionList() local playerlist = GetPlayerList() for i,p in ipairs(playerlist) do if drawCmds[p].blocked then name = GetPlayerInfo(p) if name then Spring.Echo(name .. " (" .. p .. ")") end end end end -- callins function widget:Initialize() SetupDrawCounters() if WG.Chili then Chili = WG.Chili Button = Chili.Button Control = Chili.Control Label = Chili.Label Colorbars = Chili.Colorbars Checkbox = Chili.Checkbox Trackbar = Chili.Trackbar Window = Chili.Window ScrollPanel = Chili.ScrollPanel StackPanel = Chili.StackPanel Grid = Chili.Grid TextBox = Chili.TextBox Image = Chili.Image screen0 = Chili.Screen0 --CreateTrafficWindow() --CreateDrawCmdWindow() end widgetHandler:AddAction(action_unblock, ActionUnBlock, nil, "t") widgetHandler:AddAction(action_block, ActionBlock, nil, "t") widgetHandler:AddAction(action_gui, ActionGUI, nil, "t") widgetHandler:AddAction(action_list, ActionList, nil, "t") end function widget:Shutdown() if window0 ~= nil then window0:Dispose() end if window1 ~= nil then window1:Dispose() end widgetHandler:RemoveAction(action_unlock) widgetHandler:RemoveAction(action_block) widgetHandler:RemoveAction(action_gui) widgetHandler:RemoveAction(action_list) end function widget:Update(dt) timer = timer + dt if timer > 1 then timer = 0 Output() end timerCmd = timerCmd + dt if timerCmd > timeFrame then timerCmd = 0 -- flip buffer currentCounter = currentCounter%counterNum+1 ClearCurrentBuffer() UpdateLabels() -- window1 end end --[[ point x y z str line x y z x y z erase: x y z r ]] function widget:MapDrawCmd(playerID, cmdType, a, b, c, d, e, f) if drawCmds[playerID] and validTypes[cmdType] then local val = drawCmds[playerID].counters[cmdType][currentCounter] val = val + 1 drawCmds[playerID].counters[cmdType][currentCounter] = val end return drawCmds[playerID].blocked end
gpl-2.0
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/signal/complex.lua
5
5270
--[[ All functions in here expect either a 2D Nx2 Complex tensor ]]-- local complex = {} function complex.angle(h) return torch.atan2(h[{{},2}],h[{{},1}]) end function complex.exp(h) local out = h:clone() local real = h[{{},1}] local imag = h[{{},2}] out[{{},1}] = torch.exp(real):cmul(torch.cos(imag)) out[{{},2}] = torch.exp(real):cmul(torch.sin(imag)); return out end function complex.abs(h) local hsquare = torch.pow(h,2) if h:dim() == 2 and h:size(2) == 2 then return torch.sqrt(hsquare[{{},1}] + hsquare[{{},2}]) elseif h:dim() == 3 and h:size(3) == 2 then return torch.sqrt(hsquare[{{},{},1}] + hsquare[{{},{},2}]) else error('unsupported dimensions') end end function complex.real(h) return h[{{},1}] end function complex.imag(h) return h[{{},2}] end function complex.conj(h) local out = h:clone() out[{{},2}]:mul(-1) return out end function complex.prod(h) local out = torch.ones(1,2):typeAs(h) out[1] = h[1] for i=2,h:size(1) do -- (x1 + iy1) * (x2 + iy2) = (x1x2 - y1y2) + i(x1y2 + y1x2) local real = (out[1][1]* h[i][1] - out[1][2] * h[i][2]) local imag = (out[1][1]* h[i][2] + out[1][2] * h[i][1]) out[1][1] = real out[1][2] = imag end return out end function complex.cmul(a1,b1, noargcheck) local a,b if noargcheck then a=a1; b=b1 else if a1:dim() == 1 then -- assume that imag is 0 a = torch.DoubleTensor(a1:size(1), 2):zero() a[{{}, 1}] = a1 elseif a1:dim() == 2 and a1:size(2) == 2 then a = a1 else error('Input has to be 1D Tensor of size N (purely real 1D tensor) or ' .. '2D Tensor of size Nx2 (Complex 1D tensor)') end if b1:dim() == 1 then -- assume that imag is 0 b = torch.DoubleTensor(b1:size(1), 2):zero() b[{{}, 1}] = b1 elseif b1:dim() == 2 and b1:size(2) == 2 then b = b1 else error('Input has to be 1D Tensor of size N (purely real 1D tensor) or ' .. '2D Tensor of size Nx2 (Complex 1D tensor)') end end local c = a:clone():zero() a = a:contiguous() b = b:contiguous() c = c:contiguous() local cd = torch.data(c) local ad = torch.data(a) local bd = torch.data(b) for i=0,a:size(1)-1 do -- (x1 + iy1) * (x2 + iy2) = (x1x2 - y1y2) + i(x1y2 + y1x2) local re = i*2 local im = i*2 + 1 cd[re] = (ad[re]* bd[re] - ad[im] * bd[im]) cd[im] = (ad[re]* bd[im] + ad[im] * bd[re]) end return c end function complex.dot(a,b) if not(a:dim() == 2 and a:size(2) == 2 and b:dim() == 2 and b:size(2) == 2) then error('Inputs have to be 2D Tensor of size Nx2 (complex 1D tensor)') end if a:size(1) ~= b:size(1) then error('Both inputs need to have same number of elements') end local c = torch.sum(complex.cmul(a,b, true), 1) return c end function complex.mm(a,b) if not(a:dim() == 3 and a:size(3) == 2 and b:dim() == 3 and b:size(3) == 2) then error('Inputs have to be 3D Tensor of size NxMx2 (complex 2D tensor)') end if a:size(2) ~= b:size(1) then error('Matrix-Matrix product requires NxM and MxP matrices.') end local c = torch.zeros(a:size(1), b:size(2), 2):typeAs(a) for i=1,c:size(1) do for j=1,c:size(2) do c[i][j] = complex.dot(a[{i,{},{}}], b[{{},j,{}}]) -- print(c[i][j]) end end return c end function complex.diag(x) if x:dim() == 2 and x:size(2) == 2 then local y = torch.zeros(x:size(1), x:size(1), 2) y[{{},1}] = torch.diag(x[{{},1}]) y[{{},2}] = torch.diag(x[{{},2}]) return y elseif x:dim() == 3 and x:size(3) == 2 then local yr = torch.diag(x[{{},{},1}]) local y = torch.zeros(yr:size(1),2) y[{{},1}] = yr y[{{},2}] = torch.diag(x[{{},{},2}]) return y else error('Input has to be 2D Tensor of size Nx2 or ' .. '3D Tensor of size NxMx2 (Complex 2D tensor)') end end --[[ Polynomial with specified roots Function is super unoptimized ]]-- function complex.poly(x) local e if x:dim() == 2 and x:size(1) == x:size(2) then e = torch.eig(x) -- square polynomial -- TODO: Strip out infinities in case the eigen values have any elseif x:dim() == 1 then e = x else error('Input should be a 1D Tensor or a 2D square tensor') end -- Expand recursion formula local n = e:size(1) if x:dim() == 1 then local c = torch.zeros(n+1) -- purely real c[1] = 1 for j=1,n do c[{{2,(j+1)}}] = c[{{2,(j+1)}}] - torch.mul(c[{{1,j}}],e[j]) end return c else local c = torch.zeros(n+1,2) -- complex c[1][1] = 1 for j=1,n do -- c(2:(j+1)) = c(2:(j+1)) - e(j).*c(1:j); c[{{2,(j+1)}, 1}] = c[{{2,(j+1)}, 1}] - torch.mul(c[{{1,j}, 1}],e[j][1]) c[{{2,(j+1)}, 2}] = c[{{2,(j+1)}, 2}] - torch.mul(c[{{1,j}, 2}],e[j][2]) end -- The result should be real if the roots are complex conjugates. local c1 = torch.sort(e[{{torch.ge(e[{{},2}], 0)},2}]) local c2 = torch.sort(e[{{torch.le(e[{{},2}], 0)},2}]) if c1:size(1) == c2:size(1) and torch.eq(c1, c2):sum() == c1:size(1) then c = complex.real(c); end return c end end return complex
mit
rlcevg/Zero-K
effects/nuke_150.lua
25
15829
-- nuke_150_seacloud -- nuke_150_landcloud_ring -- nuke_150_landcloud -- nuke_150_landcloud_topcap -- nuke_150_landcloud_cap -- nuke_150_seacloud_topcap -- nuke_150_seacloud_ring -- nuke_150 -- nuke_150_seacloud_cap -- nuke_150_seacloud_pillar -- nuke_150_landcloud_pillar return { ["nuke_150_seacloud"] = { usedefaultexplosions = false, cap = { air = true, class = [[CExpGenSpawner]], count = 24, ground = true, water = true, underwater = true, properties = { delay = [[i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_SEACLOUD_CAP]], pos = [[0, i8, 0]], }, }, pillar = { air = true, class = [[CExpGenSpawner]], count = 32, ground = true, water = true, underwater = true, properties = { delay = [[i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_SEACLOUD_PILLAR]], pos = [[0, i8, 0]], }, }, ring = { air = true, class = [[CExpGenSpawner]], count = 1, ground = true, water = true, underwater = true, properties = { delay = 16, dir = [[dir]], explosiongenerator = [[custom:NUKE_150_SEACLOUD_RING]], pos = [[0, 128, 0]], }, }, topcap = { air = true, class = [[CExpGenSpawner]], count = 8, ground = true, water = true, underwater = true, properties = { delay = [[24 i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_SEACLOUD_TOPCAP]], pos = [[0, 192 i8, 0]], }, }, }, ["nuke_150_landcloud_ring"] = { land = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 1 1 0.75 1 1 0.75 0.5 1 0.75 0.75 0.75 1 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 128, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 16, particlespeedspread = 1, pos = [[0, 0, 0]], sizegrowth = 8, sizemod = 0.5, texture = [[smokesmall]], }, }, }, ["nuke_150_landcloud"] = { usedefaultexplosions = false, cap = { air = true, class = [[CExpGenSpawner]], count = 24, ground = true, water = true, properties = { delay = [[i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_LANDCLOUD_CAP]], pos = [[0, i8, 0]], }, }, pillar = { air = true, class = [[CExpGenSpawner]], count = 32, ground = true, water = true, properties = { delay = [[i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_LANDCLOUD_PILLAR]], pos = [[0, i8, 0]], }, }, ring = { air = true, class = [[CExpGenSpawner]], count = 1, ground = true, water = true, properties = { delay = 16, dir = [[dir]], explosiongenerator = [[custom:NUKE_150_LANDCLOUD_RING]], pos = [[0, 128, 0]], }, }, topcap = { air = true, class = [[CExpGenSpawner]], count = 8, ground = true, water = true, properties = { delay = [[24 i1]], dir = [[dir]], explosiongenerator = [[custom:NUKE_150_LANDCLOUD_TOPCAP]], pos = [[0, 192 i8, 0]], }, }, }, ["nuke_150_landcloud_topcap"] = { land = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 1 1 0 1 1 1 1 0.75 0.25 0.25 0.25 0.5 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 4, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 4, particlespeedspread = 4, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[fireball]], }, }, }, ["nuke_150_landcloud_cap"] = { land = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 1 1 0 1 1 1 1 0.75 0.25 0.25 0.25 0.5 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 4, particlelife = 15, particlelifespread = 5, particlesize = 4, particlesizespread = 4, particlespeed = 4, particlespeedspread = 4, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[fireball]], }, }, }, ["nuke_150_seacloud_topcap"] = { cloud = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, underwater = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 0.8 0.8 1 1 0.8 0.8 1 0.75 0.8 0.8 1 0.5 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 4, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 4, particlespeedspread = 4, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[smokesmall]], }, }, }, ["nuke_150_seacloud_ring"] = { cloud = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, underwater = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 0.8 0.8 1 1 0.8 0.8 1 0.75 0.8 0.8 1 0.5 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 128, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 16, particlespeedspread = 1, pos = [[0, 0, 0]], sizegrowth = 8, sizemod = 0.5, texture = [[smokesmall]], }, }, }, ["nuke_150"] = { usedefaultexplosions = false, groundflash = { alwaysvisible = true, circlealpha = 1, circlegrowth = 10, flashalpha = 0.5, flashsize = 150, ttl = 15, color = { [1] = 1, [2] = 0.5, [3] = 0, }, }, landcloud = { air = true, class = [[CExpGenSpawner]], count = 1, ground = true, properties = { delay = 15, dir = [[dir]], explosiongenerator = [[custom:NUKE_150_LANDCLOUD]], pos = [[0, 0, 0]], }, }, landdirt = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, properties = { airdrag = 0.95, alwaysvisible = true, colormap = [[0 0 0 0 0.5 0.4 0.3 1 0.6 0.4 0.2 0.75 0.5 0.4 0.3 0.5 0 0 0 0]], directional = false, emitrot = 85, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.1, 0]], numparticles = 64, particlelife = 30, particlelifespread = 5, particlesize = 4, particlesizespread = 4, particlespeed = 2, particlespeedspread = 12, pos = [[0, 0, 0]], sizegrowth = 8, sizemod = 0.75, texture = [[dirt]], }, }, pikes = { air = true, class = [[explspike]], count = 32, ground = true, water = true, properties = { alpha = 1, alphadecay = 0.025, alwaysvisible = true, color = [[1,0.5,0.1]], dir = [[-8 r16, -8 r16, -8 r16]], length = 1, lengthgrowth = 1, width = 64, }, }, seacloud = { class = [[CExpGenSpawner]], count = 1, water = true, underwater = true, properties = { delay = 15, dir = [[dir]], explosiongenerator = [[custom:NUKE_150_SEACLOUD]], pos = [[0, 0, 0]], }, }, sphere = { air = true, class = [[CSpherePartSpawner]], count = 1, ground = true, water = true, underwater = true, properties = { alpha = 0.5, color = [[1,1,0.5]], expansionspeed = 15, ttl = 20, }, }, watermist = { class = [[CSimpleParticleSystem]], count = 1, water = true, underwater = true, properties = { airdrag = 0.99, alwaysvisible = true, colormap = [[0 0 0 0 0.8 0.8 1 1 0.8 0.8 1 0.75 0.8 0.8 1 0.5 0 0 0 0]], directional = false, emitrot = 0, emitrotspread = 90, emitvector = [[0, 1, 0]], gravity = [[0, -0.2, 0]], numparticles = 16, particlelife = 30, particlelifespread = 5, particlesize = 4, particlesizespread = 4, particlespeed = 6, particlespeedspread = 1, pos = [[0, 0, 0]], sizegrowth = 4, sizemod = 1, texture = [[smokesmall]], }, }, }, ["nuke_150_seacloud_cap"] = { cloud = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, underwater = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 0.8 0.8 1 1 0.8 0.8 1 0.75 0.8 0.8 1 0.5 0 0 0 0]], directional = false, emitrot = 90, emitrotspread = 5, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 4, particlelife = 15, particlelifespread = 5, particlesize = 4, particlesizespread = 4, particlespeed = 4, particlespeedspread = 4, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[smokesmall]], }, }, }, ["nuke_150_seacloud_pillar"] = { cloud = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, underwater = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 0.8 0.8 1 1 0.8 0.8 1 0.75 0.8 0.8 1 0.5 0 0 0 0]], directional = false, emitrot = 0, emitrotspread = 90, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 1, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 1, particlespeedspread = 1, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[smokesmall]], }, }, }, ["nuke_150_landcloud_pillar"] = { land = { air = true, class = [[CSimpleParticleSystem]], count = 1, ground = true, water = true, properties = { airdrag = 0.9, alwaysvisible = true, colormap = [[0 0 0 0 1 1 0.5 1 1 0.75 0.5 0.75 0.25 0.25 0.25 0.5 0 0 0 0]], directional = false, emitrot = 0, emitrotspread = 90, emitvector = [[0, 1, 0]], gravity = [[0, 0.2, 0]], numparticles = 1, particlelife = 60, particlelifespread = 10, particlesize = 4, particlesizespread = 4, particlespeed = 1, particlespeedspread = 1, pos = [[0, 0, 0]], sizegrowth = 16, sizemod = 0.75, texture = [[smokesmall]], }, }, }, }
gpl-2.0
omid1212/ccd
plugins/media.lua
376
1679
do local function run(msg, matches) local receiver = get_receiver(msg) local url = matches[1] local ext = matches[2] local file = download_to_file(url) local cb_extra = {file_path=file} local mime_type = mimetype.get_content_type_no_sub(ext) if ext == 'gif' then print('send_file') send_document(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'text' then print('send_document') send_document(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'image' then print('send_photo') send_photo(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'audio' then print('send_audio') send_audio(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'video' then print('send_video') send_video(receiver, file, rmtmp_cb, cb_extra) else print('send_file') send_file(receiver, file, rmtmp_cb, cb_extra) end end return { description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.", usage = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.", patterns = { "(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$" }, run = run } end
gpl-2.0
stas2z/openwrt-witi
feeds/packages/net/mwan3-luci/files/usr/lib/lua/luci/model/cbi/mwan/rule.lua
80
4829
-- ------ extra functions ------ -- function ruleCheck() -- determine if rules needs a proper protocol configured uci.cursor():foreach("mwan3", "rule", function (section) local sourcePort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".src_port")) local destPort = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".dest_port")) if sourcePort ~= "" or destPort ~= "" then -- ports configured local protocol = ut.trim(sys.exec("uci -p /var/state get mwan3." .. section[".name"] .. ".proto")) if protocol == "" or protocol == "all" then -- no or improper protocol error_protocol_list = error_protocol_list .. section[".name"] .. " " end end end ) end function ruleWarn() -- display warning messages at the top of the page if error_protocol_list ~= " " then return "<font color=\"ff0000\"><strong>WARNING: some rules have a port configured with no or improper protocol specified! Please configure a specific protocol!</strong></font>" else return "" end end -- ------ rule configuration ------ -- dsp = require "luci.dispatcher" sys = require "luci.sys" ut = require "luci.util" error_protocol_list = " " ruleCheck() m5 = Map("mwan3", translate("MWAN Rule Configuration"), translate(ruleWarn())) m5:append(Template("mwan/config_css")) mwan_rule = m5:section(TypedSection, "rule", translate("Traffic Rules"), translate("Rules specify which traffic will use a particular MWAN policy based on IP address, port or protocol<br />" .. "Rules are matched from top to bottom. Rules below a matching rule are ignored. Traffic not matching any rule is routed using the main routing table<br />" .. "Traffic destined for known (other than default) networks is handled by the main routing table. Traffic matching a rule, but all WAN interfaces for that policy are down will be blackholed<br />" .. "Names may contain characters A-Z, a-z, 0-9, _ and no spaces<br />" .. "Rules may not share the same name as configured interfaces, members or policies")) mwan_rule.addremove = true mwan_rule.anonymous = false mwan_rule.dynamic = false mwan_rule.sectionhead = "Rule" mwan_rule.sortable = true mwan_rule.template = "cbi/tblsection" mwan_rule.extedit = dsp.build_url("admin", "network", "mwan", "configuration", "rule", "%s") function mwan_rule.create(self, section) TypedSection.create(self, section) m5.uci:save("mwan3") luci.http.redirect(dsp.build_url("admin", "network", "mwan", "configuration", "rule", section)) end src_ip = mwan_rule:option(DummyValue, "src_ip", translate("Source address")) src_ip.rawhtml = true function src_ip.cfgvalue(self, s) return self.map:get(s, "src_ip") or "&#8212;" end src_port = mwan_rule:option(DummyValue, "src_port", translate("Source port")) src_port.rawhtml = true function src_port.cfgvalue(self, s) return self.map:get(s, "src_port") or "&#8212;" end dest_ip = mwan_rule:option(DummyValue, "dest_ip", translate("Destination address")) dest_ip.rawhtml = true function dest_ip.cfgvalue(self, s) return self.map:get(s, "dest_ip") or "&#8212;" end dest_port = mwan_rule:option(DummyValue, "dest_port", translate("Destination port")) dest_port.rawhtml = true function dest_port.cfgvalue(self, s) return self.map:get(s, "dest_port") or "&#8212;" end proto = mwan_rule:option(DummyValue, "proto", translate("Protocol")) proto.rawhtml = true function proto.cfgvalue(self, s) return self.map:get(s, "proto") or "all" end sticky = mwan_rule:option(DummyValue, "sticky", translate("Sticky")) sticky.rawhtml = true function sticky.cfgvalue(self, s) if self.map:get(s, "sticky") == "1" then stickied = 1 return "Yes" else stickied = nil return "No" end end timeout = mwan_rule:option(DummyValue, "timeout", translate("Sticky timeout")) timeout.rawhtml = true function timeout.cfgvalue(self, s) if stickied then local timeoutValue = self.map:get(s, "timeout") if timeoutValue then return timeoutValue .. "s" else return "600s" end else return "&#8212;" end end ipset = mwan_rule:option(DummyValue, "ipset", translate("IPset")) ipset.rawhtml = true function ipset.cfgvalue(self, s) return self.map:get(s, "ipset") or "&#8212;" end use_policy = mwan_rule:option(DummyValue, "use_policy", translate("Policy assigned")) use_policy.rawhtml = true function use_policy.cfgvalue(self, s) return self.map:get(s, "use_policy") or "&#8212;" end errors = mwan_rule:option(DummyValue, "errors", translate("Errors")) errors.rawhtml = true function errors.cfgvalue(self, s) if not string.find(error_protocol_list, " " .. s .. " ") then return "" else return "<span title=\"No protocol specified\"><img src=\"/luci-static/resources/cbi/reset.gif\" alt=\"error\"></img></span>" end end return m5
gpl-2.0
DrFR0ST/Human-Apocalypse
lib/shine/dmg.lua
8
4822
--[[ The MIT License (MIT) Copyright (c) 2015 Josef Patoprsty 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. ]]-- local palettes = { -- Default color palette. Source: -- http://en.wikipedia.org/wiki/List_of_video_game_console_palettes#Original_Game_Boy { name = "default", colors = { { 15/255, 56/255, 15/255}, { 48/255, 98/255, 48/255}, {139/255,172/255, 15/255}, {155/255,188/255, 15/255} } }, -- Hardcore color profiles. Source: -- http://www.hardcoregaming101.net/gbdebate/gbcolours.htm { name = "dark_yellow", colors = { {33/255,32/255,16/255}, {107/255,105/255,49/255}, {181/255,174/255,74/255}, {255/255,247/255,123/255} } }, { name = "light_yellow", colors = { {102/255,102/255,37/255}, {148/255,148/255,64/255}, {208/255,208/255,102/255}, {255/255,255/255,148/255} } }, { name = "green", colors = { {8/255,56/255,8/255}, {48/255,96/255,48/255}, {136/255,168/255,8/255}, {183/255,220/255,17/255} } }, { name = "greyscale", colors = { {56/255,56/255,56/255}, {117/255,117/255,117/255}, {178/255,178/255,178/255}, {239/255,239/255,239/255} } }, { name = "stark_bw", colors = { {0/255,0/255,0/255}, {117/255,117/255,117/255}, {178/255,178/255,178/255}, {255/255,255/255,255/255} } }, { name = "pocket", colors = { {108/255,108/255,78/255}, {142/255,139/255,87/255}, {195/255,196/255,165/255}, {227/255,230/255,201/255} } } } local lookup_palette = function(name) for _,palette in pairs(palettes) do if palette.name == name then return palette end end end return { description = "DMG Color Emulation", new = function(self) self.canvas = love.graphics.newCanvas() self.shader = love.graphics.newShader[[ extern number value; uniform vec3 palette[ 4 ]; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){ vec4 pixel = Texel(texture, texture_coords); float avg = min(0.9999,max(0.0001,(pixel.r + pixel.g + pixel.b)/3)); int index = int(avg*4); pixel.r = palette[index][0]; pixel.g = palette[index][1]; pixel.b = palette[index][2]; return pixel; } ]] self.shader:send('palette',unpack(palettes[1].colors)) end, draw = function(self, func, ...) self:_apply_shader_to_scene(self.shader, self.canvas, func, ...) end, set = function(self, key, value) if key == "palette" then local palette if type(value) == "number" and palettes[math.floor(value)] then -- Check if value is an index palette = palettes[math.floor(value)] elseif type(value) == "string" then -- Check if value is a named palette palette = lookup_palette(value) elseif type(value) == "table" then -- Check if value is a custom palette. -- Needs to match: {{R,G,B},{R,G,B},{R,G,B},{R,G,B}} local valid = true -- Table needs to have four indexes of tables for color_2bit = 1,4 do if value[color_2bit] and type(value[color_2bit]) == "table" then -- Table needs to have three indexes of floats 0..1 for color_channel = 1,3 do if value[color_2bit][color_channel] and type(value[color_2bit][color_channel]) == "number" then if value[color_2bit][color_channel] < 0 or value[color_2bit][color_channel] > 1 then -- Number is not a float 0..1 valid = false end else -- Table does not have three indexes of numbers valid = false end end else -- Table does not have four indexes of tables valid = false end end -- Fall back on failure palette = valid and {colors=value} or palettes[1] else -- Fall back to default palette = palettes[1] end self.shader:send(key,unpack(palette.colors)) else error("Unknown property: " .. tostring(key)) end return self end }
mit
Satoshi-t/Re-SBS
lang/zh_CN/Package/NostalgiaPackage.lua
1
17736
-- translation for Nostalgia Package return { ["nostalgia"] = "怀旧卡牌", ["moon_spear"] = "银月枪X", [":moon_spear"] = "装备牌·武器<br /><b>攻击范围</b>:3<br /><b>武器技能</b>:你的回合外,每当你使用或打出了一张黑色牌时,你可以使用一张【杀】", ["@moon-spear-slash"] = "【银月枪】效果被触发,你可以使用一张【杀】", ["nostal_general"] = "怀旧-测试", ["nostal_standard"] = "怀旧-标准", ["nostal_wind"] = "怀旧-风", ["nostal_yjcm"] = "怀旧-一将", ["nostal_yjcm2012"] = "怀旧-一将2", ["nostal_yjcm2013"] = "怀旧-一将3", ["nos_caocao"] = "曹操-旧", ["&nos_caocao"] = "曹操", ["nosjianxiong"] = "奸雄", [":nosjianxiong"] = "每当你受到伤害后,你可以获得对你造成伤害的牌。", ["nos_simayi"] = "司马懿-旧", ["&nos_simayi"] = "司马懿", ["nosfankui"] = "反馈", [":nosfankui"] = "每当你受到伤害后,你可以获得伤害来源的一张牌。", ["nosguicai"] = "鬼才", [":nosguicai"] = "每当一名角色的判定牌生效前,你可以打出一张手牌代替之。", ["@nosguicai-card"] = CommonTranslationTable["@askforretrial"], ["~nosguicai"] = "选择一张手牌→点击确定", ["nos_xiahoudun"] = "夏侯惇-旧", ["&nos_xiahoudun"] = "夏侯惇", ["nosganglie"] = "刚烈", [":nosganglie"] = "每当你受到伤害后,你可以进行判定:若结果不为红桃,则伤害来源选择一项:弃置两张手牌,或受到1点伤害。", ["nos_zhangliao"] = "张辽-旧", ["&nos_zhangliao"] = "张辽", ["nostuxi"] = "突袭", [":nostuxi"] = "摸牌阶段开始时,你可以放弃摸牌并选择一至两名有手牌的其他角色:若如此做,你依次获得这些角色各一张手牌。", ["@nostuxi-card"] = "你可以发动“突袭”", ["~nostuxi"] = "选择 1-2 名其他角色→点击确定", ["nos_xuchu"] = "许褚-旧", ["&nos_xuchu"] = "许褚", ["nosluoyi"] = "裸衣", [":nosluoyi"] = "摸牌阶段,你可以少摸一张牌:若如此做,本回合你使用【杀】或【决斗】对目标角色造成伤害时,此伤害+1。", ["nos_guojia"] = "郭嘉-旧", ["&nos_guojia"] = "郭嘉", ["nosyiji"] = "遗计", [":nosyiji"] = "每当你受到1点伤害后,你可以观看牌堆顶的两张牌,然后将这两张牌任意分配。", ["nos_liubei"] = "刘备-旧", ["&nos_liubei"] = "刘备", ["nosrende"] = "仁德", [":nosrende"] = "出牌阶段,你可以将至少一张手牌任意分配给其他角色。你于本阶段内以此法给出的手牌首次达到两张或更多后,你回复1点体力。", ["nos_guanyu"] = "关羽-旧", ["&nos_guanyu"] = "关羽", ["nos_zhangfei"] = "张飞-旧", ["&nos_zhangfei"] = "张飞", ["#nos_zhaoyun"] = "少年将军", ["nos_zhaoyun"] = "赵云-旧", ["&nos_zhaoyun"] = "赵云", ["nos_machao"] = "马超-旧", ["&nos_machao"] = "马超", ["nostieji"] = "铁骑", [":nostieji"] = "每当你指定【杀】的目标后,你可以进行判定:若结果为红色,该角色不能使用【闪】响应此【杀】。", ["nos_huangyueying"] = "黄月英-旧", ["&nos_huangyueying"] = "黄月英", ["nosjizhi"] = "集智", [":nosjizhi"] = "每当你使用一张非延时锦囊牌时,你可以摸一张牌。", ["nosqicai"] = "奇才", [":nosqicai"] = "锁定技。你使用锦囊牌无距离限制。", ["nos_ganning"] = "甘宁-旧", ["&nos_ganning"] = "甘宁", ["#nos_lvmeng"] = "白衣渡江", ["nos_lvmeng"] = "吕蒙-旧", ["&nos_lvmeng"] = "吕蒙", ["nos_huanggai"] = "黄盖-旧", ["&nos_huanggai"] = "黄盖", ["noskurou"] = "苦肉", [":noskurou"] = "出牌阶段,你可以失去1点体力:若如此做,你摸两张牌。", ["nos_luxun"] = "陆逊-旧", ["&nos_luxun"] = "陆逊", ["nosqianxun"] = "谦逊", [":nosqianxun"] = "锁定技。你不能被选择为【顺手牵羊】与【乐不思蜀】的目标。", ["noslianying"] = "连营", [":noslianying"] = "每当你失去最后的手牌后,你可以摸一张牌。", ["nos_zhouyu"] = "周瑜-旧", ["&nos_zhouyu"] = "周瑜", ["nosyingzi"] = "英姿", [":nosyingzi"] = "摸牌阶段,你可以额外摸一张牌。", ["nosfanjian"] = "反间", [":nosfanjian"] = "阶段技。你可以令一名其他角色选择一种花色,然后正面朝上获得你的一张手牌。若此牌花色与该角色所选花色不同,该角色受到1点伤害。", ["nos_daqiao"] = "大乔-旧", ["&nos_daqiao"] = "大乔", ["nosguose"] = "国色", [":nosguose"] = "你可以将一张方块牌当【乐不思蜀】使用。", ["nos_huatuo"] = "华佗-旧", ["&nos_huatuo"] = "华佗", ["qingnang"] = "青囊", [":qingnang"] = "阶段技。你可以弃置一张手牌并选择一名已受伤的角色:若如此做,该角色回复1点体力。", ["nos_lvbu"] = "吕布-旧", ["&nos_lvbu"] = "吕布", ["nos_diaochan"] = "貂蝉-旧", ["&nos_diaochan"] = "貂蝉", ["noslijian"] = "离间", [":noslijian"] = "阶段技。你可以弃置一张牌并选择两名男性角色:若如此做,视为其中一名角色对另一名角色使用一张【决斗】,此【决斗】不能被【无懈可击】响应。", ["nos_caoren"] = "曹仁-旧", ["&nos_caoren"] = "曹仁", ["nosjushou"] = "据守", [":nosjushou"] = "结束阶段开始时,你可以摸三张牌,然后将武将牌翻面。", ["nos_zhoutai"] = "周泰-旧", ["&nos_zhoutai"] = "周泰", ["nosbuqu"] = "不屈", [":nosbuqu"] = "每当你扣减1点体力后,若你的体力值为0或更低,你可以将牌堆顶的一张牌置于你的武将牌上,然后若无同点数的“不屈牌”,你不进入濒死状态。每当你回复1点体力后,你将一张“不屈牌”置入弃牌堆。", ["#NosBuquDuplicate"] = "%from 发动“<font color=\"yellow\"><b>不屈</b></font>”失败,其“不屈牌”中有 %arg 组重复点数", ["#NosBuquDuplicateGroup"] = "第 %arg 组重复点数为 %arg2", ["$NosBuquDuplicateItem"] = "重复“不屈牌”: %card", ["$NosBuquRemove"] = "%from 移除了“不屈牌”:%card", ["nos_zhangjiao"] = "张角-旧", ["&nos_zhangjiao"] = "张角", ["illustrator:nos_zhangjiao"] = "LiuHeng", ["nosleiji"] = "雷击", [":nosleiji"] = "每当你使用或打出一张【闪】时,你可以令一名角色进行判定:若结果为黑桃,你对该角色造成2点雷电伤害。", ["nos_yuji"] = "于吉-旧", ["&nos_yuji"] = "于吉", ["nosguhuo"] = "蛊惑", [":nosguhuo"] = "你可以扣置一张手牌当做一张基本牌或非延时锦囊牌使用或打出,体力值大于0的其他角色选择是否质疑,然后你展示此牌:若无角色质疑,此牌按你所述继续结算;若有角色质疑:若此牌为真,质疑角色各失去1点体力,否则质疑角色各摸一张牌;且若此牌为红桃且为真,则按你所述继续结算结算,否则将之置入弃牌堆。", ["nosguhuo_saveself"] = "“蛊惑”【桃】或【酒】", ["nosguhuo_slash"] = "“蛊惑”【杀】", ["nos_fazheng"] = "法正-旧", ["&nos_fazheng"] = "法正", ["designer:nos_fazheng"] = "Michael_Lee", ["illustrator:nos_fazheng"] = "雷没才", ["nosenyuan"] = "恩怨", [":nosenyuan"] = "锁定技。每当你回复1点体力后,令你回复体力的角色摸一张牌;每当你受到伤害后,伤害来源选择一项:交给你一张红桃手牌,或失去1点体力。", ["@nosenyuan-heart"] = "请给出一张红桃手牌", ["nosxuanhuo"] = "眩惑", [":nosxuanhuo"] = "阶段技。你可以将一张红桃手牌交给一名其他角色:若如此做,你获得该角色的一张牌,然后将此牌交给除该角色外的另一名角色。", ["@nosxuanhuo-give"] = "你可以将此牌交给除 %src 外的一名角色", ["nos_xushu"] = "YJ徐庶-旧", ["&nos_xushu"] = "徐庶", ["designer:nos_xushu"] = "双叶松", ["illustrator:nos_xushu"] = "XINA", ["noswuyan"] = "无言", [":noswuyan"] = "锁定技。你使用的非延时锦囊牌对其他角色无效。其他角色使用的非延时锦囊牌对你无效", ["nosjujian"] = "举荐", [":nosjujian"] = "阶段技。你可以弃置至多三张牌并选择一名其他角色:若如此做,该角色摸等量的牌。若你以此法弃置三张同一类别的牌,你回复1点体力。", ["#WuyanBaD"] = "%from 的“%arg2”被触发,对 %to 的锦囊【%arg】无效", ["#WuyanGooD"] = "%from 的“%arg2”被触发, %to 的锦囊【%arg】对其无效", ["#JujianRecover"] = "%from 发动“<font color=\"yellow\"><b>举荐</b></font>”弃置了三张 %arg ,回复1点体力", ["nos_lingtong"] = "凌统-旧", ["&nos_lingtong"] = "凌统", ["designer:nos_lingtong"] = "ShadowLee", ["illustrator:nos_lingtong"] = "绵Myan", ["nosxuanfeng"] = "旋风", [":nosxuanfeng"] = "每当你失去一次装备区的牌后,你可以选择一项:视为使用一张无距离限制的【杀】,或对距离1的一名角色造成1点伤害", ["nosxuanfeng:nothing"] = "不发动", ["nosxuanfeng:damage"] = "对距离1的其他角色造成1点伤害", ["nosxuanfeng:slash"] = "视为对一名其他角色使用一张【杀】", ["@nosxuanfeng-damage"] = "请选择距离1的一名角色", ["nos_zhangchunhua"] = "张春华-旧", ["&nos_zhangchunhua"] = "张春华", ["designer:nos_zhangchunhua"] = "JZHIEI", ["illustrator:nos_zhangchunhua"] = "樱花闪乱", ["nosshangshi"] = "伤逝", [":nosshangshi"] = "每当你的手牌数、体力值或体力上限改变后,若你的手牌数小于X,你可以将手牌补至X张。(X为你已损失的体力值)", ["nos_handang"] = "韩当-旧", ["&nos_handang"] = "韩当", ["designer:nos_handang"] = "ByArt", ["illustrator:nos_handang"] = "DH", ["nosgongqi"] = "弓骑", [":nosgongqi"] = "你可以将一张装备牌当【杀】使用或打出。你以此法使用的【杀】无距离限制。", ["nosjiefan"] = "解烦", [":nosjiefan"] = "你的回合外,每当一名角色处于濒死状态时,你可以对当前回合角色使用一张【杀】:若此【杀】造成伤害,造成伤害时防止此伤害,视为对该濒死角色使用了一张【桃】。", ["nosjiefan-slash"] = "请对当前回合角色使用一张【杀】", ["#NosJiefanPrevent"] = "%from 的“<font color=\"yellow\"><b>解烦</b></font>”效果被触发,防止了对 %to 的伤害", ["#NosJiefanNull1"] = "%from 已经脱离濒死状态,“<font color=\"yellow\"><b>解烦</b></font>”第二项效果无法执行", ["#NosJiefanNull2"] = "%from 已经死亡,“<font color=\"yellow\"><b>解烦</b></font>”第二项效果无法执行", ["#NosJiefanNull3"] = "因为当前回合角色 %from 拥有“<font color=\"yellow\"><b>完杀</b></font>”技能, %to 不处于濒死状态,“<font color=\"yellow\"><b>解烦</b></font>”第二项效果无法执行", ["nos_wangyi"] = "王异-旧", ["&nos_wangyi"] = "王异", ["designer:nos_wangyi"] = "Virgopal", ["illustrator:nos_wangyi"] = "木美人", ["noszhenlie"] = "贞烈", [":noszhenlie"] = "每当你的判定牌生效前,你可以亮出牌堆顶的一张牌代替之。", ["nosmiji"] = "秘计", [":nosmiji"] = "回合开始或结束阶段开始时,若你已受伤,你可以进行判定:若结果为黑色,你观看牌堆顶的X张牌然后将之交给一名角色。(X为你已损失的体力值)", ["nos_madai"] = "马岱-旧", ["&nos_madai"] = "马岱", ["designer:nos_madai"] = "凌天翼", ["illustrator:nos_madai"] = "大佬荣", ["nosqianxi"] = "潜袭", [":nosqianxi"] = "每当你使用【杀】对距离1的目标角色造成伤害时,你可以进行判定:若结果不为红桃,防止此伤害,该角色失去1点体力上限。", ["nos_guanxingzhangbao"] = "关&张-旧", ["&nos_guanxingzhangbao"] = "关兴张苞", ["designer:nos_guanxingzhangbao"] = "诺思冥羽", ["illustrator:nos_guanxingzhangbao"] = "HOOO", ["nosfuhun"] = "父魂", [":nosfuhun"] = "摸牌阶段开始时,你可以放弃摸牌,亮出牌堆顶的两张牌并获得之:若亮出的牌不为同一颜色,你拥有“武圣”、“咆哮”,直到回合结束。", ["nos_caochong"] = "曹冲-旧", ["&nos_caochong"] = "曹冲", ["designer:nos_caochong"] = "红魔7号", ["illustrator:nos_caochong"] = "Amo", ["noschengxiang"] = "称象", [":noschengxiang"] = "每当你受到伤害后,你可以亮出牌堆顶的四张牌,然后获得其中至少一张点数之和小于13的牌,并将其余的牌置入弃牌堆。", ["nosrenxin"] = "仁心", [":nosrenxin"] = "每当一名其他角色处于濒死状态时,若你有手牌,你可以将武将牌翻面并将所有手牌交给该角色:若如此做,该角色回复1点体力。", ["nos_zhuran"] = "朱然-旧", ["&nos_zhuran"] = "朱然", ["designer:nos_zhuran"] = "迁迁婷婷", ["illustrator:nos_zhuran"] = "Ccat", ["nosdanshou"] = "胆守", [":nosdanshou"] = "每当你造成伤害后,你可以摸一张牌,然后结束当前回合并结束一切结算。", ["nos_fuhuanghou"] = "伏皇后-旧", ["&nos_fuhuanghou"] = "伏皇后", ["designer:nos_fuhuanghou"] = "萌D", ["illustrator:nos_fuhuanghou"] = "小莘", ["noszhuikong"] = "惴恐", [":noszhuikong"] = "一名其他角色的回合开始时,若你已受伤,你可以与其拼点:若你赢,该角色跳过出牌阶段;若你没赢,该角色无视与你的距离,直到回合结束。", ["nosqiuyuan"] = "求援", [":nosqiuyuan"] = "每当你成为【杀】的目标时,你可以令一名除此【杀】使用者外的有手牌的其他角色正面朝上交给你一张手牌:若此牌不为【闪】,该角色也成为此【杀】的目标。", ["nosqiuyuan-invoke"] = "你可以发动“求援”<br/> <b>操作提示</b>: 选择除此【杀】使用者外的一名有手牌的其他角色→点击确定<br/>", ["@nosqiuyuan-give"] = "请交给 %src 一张手牌", ["nos_liru"] = "李儒-旧", ["&nos_liru"] = "李儒", ["designer:nos_liru"] = "进化论", ["illustrator:nos_liru"] = "MSNZero", ["nosjuece"] = "绝策", [":nosjuece"] = "你的回合内,一名体力值大于0的角色失去最后的手牌后,你可以对其造成1点伤害。", ["nosmieji"] = "灭计", [":nosmieji"] = "锁定技。你使用黑色非延时锦囊牌的目标数上限至少为二。", ["~nosmieji"] = "选择【借刀杀人】的目标角色→选择【杀】的目标角色→点击确定", ["nosfencheng"] = "焚城", [":nosfencheng"] = "限定技。出牌阶段,你可以令所有其他角色弃置X张牌,否则你对该角色造成1点火焰伤害。(X为该角色装备区牌的数量且至少为1)", ["$NosFenchengAnimate"] = "image=image/animate/nosfencheng.png", ["nos_zhonghui"] = "钟会-内测", ["&nos_zhonghui"] = "钟会", ["illustrator:nos_zhonghui"] = "雪君S", ["noszhenggong"] = "争功", [":noszhenggong"] = "每当你受到伤害后,你可以获得伤害来源装备区中的一张装备牌,然后将之置入你的装备区。", ["noszhenggong:weapon"] = "武器", ["noszhenggong:armor"] = "防具", ["noszhenggong:dhorse"] = "+1坐骑", ["noszhenggong:ohorse"] = "-1坐骑", ["nosquanji"] = "权计", [":nosquanji"] = "其他角色的回合开始时,你可以与该角色拼点:若你赢,该角色跳过准备阶段和判定阶段。", ["nospower"] = "权", ["nosbaijiang"] = "拜将", [":nosbaijiang"] = "觉醒技。准备阶段开始时,若你的装备区的装备牌大于或等于三张,你增加1点体力上限,回复1点体力,然后失去“权计”和“争功”并获得“野心”(每当你造成或受到伤害后,你可以将牌堆顶的一张牌置于武将牌上,称为“权”。阶段技。你可以将至少一张手牌与等量的“权”交换)。", ["$NosBaijiangAnimate"] = "image=image/animate/nosbaijiang.png", ["nosyexin"] = "野心", [":nosyexin"] = "每当你造成或受到伤害后,你可以将牌堆顶的一张牌置于武将牌上,称为“权”。阶段技。你可以将至少一张手牌与等量的“权”交换。", ["noszili"] = "自立", [":noszili"] = "觉醒技。准备阶段开始时,若你的“权”大于或等于四张,你失去1点体力上限,然后获得“排异”(结束阶段开始时,你可以将一张“权”移动至一名角色的手牌、装备区(若该“权”为装备牌)或判定区(若该“权”为延时锦囊牌):若该角色不是你,你摸一张牌)。", ["#NosZiliWake"] = "%from 的“权”为 %arg 张,触发“%arg2”觉醒", ["$NosZiliAnimate"] = "image=image/animate/noszili.png", ["nospaiyi"] = "排异", [":nospaiyi"] = "结束阶段开始时,你可以将一张“权”移动至一名角色的手牌、装备区(若该“权”为装备牌)或判定区(若该“权”为延时锦囊牌):若该角色不是你,你摸一张牌。", ["@nospaiyi-to"] = "请选择移动【%arg】的目标角色", ["nospaiyi:Judging"] = "判定区", ["nospaiyi:Equip"] = "装备区", ["nospaiyi:Hand"] = "手牌", ["#NosBaijiangWake"] = "%from 的装备区有 %arg 张装备牌,触发“%arg2”觉醒", ["nos_shencaocao"] = "神曹操-内测", ["&nos_shencaocao"] = "神曹操", ["nosguixin"] = "归心", [":nosguixin"] = "结束阶段开始时,你可以选择一项:1.改变一名其他角色的势力。 2.获得并可以发动一名已死亡或未上场角色的主公技。", ["nosguixin:modify"] = "改变一名其他角色的势力", ["nosguixin:obtain"] = "获得一项主公技", ["nosguixin_kingdom"] = "归心-改变势力", ["nosguixin_lordskills"] = "归心-获得技能", }
gpl-3.0
jaxfrank/UnamedFactorioMod
prototypes/technology.lua
1
5127
data:extend ({ { type = "technology", name = "character-logistic-slots-5", icon = "__base__/graphics/technology/character-logistic-slots.png", effects = { { type = "character-logistic-slots", modifier = 5 } }, prerequisites = {"character-logistic-slots-4"}, unit = { count = 150, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1}, {"alien-science-pack", 1} }, time = 30 }, upgrade = true, order = "c-k-e-d" }, { type = "technology", name = "character-logistic-slots-6", icon = "__base__/graphics/technology/character-logistic-slots.png", effects = { { type = "character-logistic-slots", modifier = 5 } }, prerequisites = {"character-logistic-slots-5"}, unit = { count = 150, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1}, {"alien-science-pack", 1} }, time = 30 }, upgrade = true, order = "c-k-e-d" }, { type = "technology", name = "character-logistic-slots-7", icon = "__base__/graphics/technology/character-logistic-slots.png", effects = { { type = "character-logistic-slots", modifier = 5 } }, prerequisites = {"character-logistic-slots-6"}, unit = { count = 150, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1}, {"alien-science-pack", 1} }, time = 30 }, upgrade = true, order = "c-k-e-d" }, { type = "technology", name = "character-logistic-slots-8", icon = "__base__/graphics/technology/character-logistic-slots.png", effects = { { type = "character-logistic-slots", modifier = 5 } }, prerequisites = {"character-logistic-slots-7"}, unit = { count = 150, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1}, {"alien-science-pack", 1} }, time = 30 }, upgrade = true, order = "c-k-e-d" }, { type = "technology", name = "character-logistic-trash-slots-3", icon = "__base__/graphics/technology/character-logistic-trash-slots.png", effects = { { type = "character-logistic-trash-slots", modifier = 5 } }, prerequisites = {"character-logistic-trash-slots-2"}, unit = { count = 100, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1} }, time = 30 }, upgrade = true, order = "c-k-f-b" }, { type = "technology", name = "character-logistic-trash-slots-4", icon = "__base__/graphics/technology/character-logistic-trash-slots.png", effects = { { type = "character-logistic-trash-slots", modifier = 5 } }, prerequisites = {"character-logistic-trash-slots-3"}, unit = { count = 100, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1} }, time = 30 }, upgrade = true, order = "c-k-f-b" }, { type = "technology", name = "logistics-4", icon = "__base__/graphics/technology/logistics.png", effects = { { type = "unlock-recipe", recipe = "very-fast-inserter" }, { type = "unlock-recipe", recipe = "fast-long-handed-inserter" }, }, prerequisites = {"logistics-3", "automation-3"}, unit = { count = 200, ingredients = { {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1} }, time = 30 }, order = "a-f-c", }, { type = "technology", name = "logistic-robot-speed-6", icon = "__base__/graphics/technology/logistic-robot-speed.png", effects = { { type = "logistic-robot-speed", modifier = "0.75" } }, prerequisites = { "logistic-robot-speed-5" }, unit = { count = 650, ingredients = { {"alien-science-pack", 1}, {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1} }, time = 60 }, upgrade = true, order = "c-k-f-e" }, { type = "technology", name = "logistic-robot-speed-7", icon = "__base__/graphics/technology/logistic-robot-speed.png", effects = { { type = "logistic-robot-speed", modifier = "0.85" } }, prerequisites = { "logistic-robot-speed-6" }, unit = { count = 800, ingredients = { {"alien-science-pack", 1}, {"science-pack-1", 1}, {"science-pack-2", 1}, {"science-pack-3", 1} }, time = 60 }, upgrade = true, order = "c-k-f-e" }, })
mit
Jennal/cocos2dx-3.2-qt
cocos/scripting/lua-bindings/auto/api/TMXObjectGroup.lua
6
1907
-------------------------------- -- @module TMXObjectGroup -- @extend Ref -- @parent_module cc -------------------------------- -- @function [parent=#TMXObjectGroup] setPositionOffset -- @param self -- @param #vec2_table vec2 -------------------------------- -- @function [parent=#TMXObjectGroup] getProperty -- @param self -- @param #string str -- @return Value#Value ret (return value: cc.Value) -------------------------------- -- @function [parent=#TMXObjectGroup] getPositionOffset -- @param self -- @return vec2_table#vec2_table ret (return value: vec2_table) -------------------------------- -- @function [parent=#TMXObjectGroup] getObject -- @param self -- @param #string str -- @return map_table#map_table ret (return value: map_table) -------------------------------- -- @overload self -- @overload self -- @function [parent=#TMXObjectGroup] getObjects -- @param self -- @return array_table#array_table ret (retunr value: array_table) -------------------------------- -- @function [parent=#TMXObjectGroup] setGroupName -- @param self -- @param #string str -------------------------------- -- @overload self -- @overload self -- @function [parent=#TMXObjectGroup] getProperties -- @param self -- @return map_table#map_table ret (retunr value: map_table) -------------------------------- -- @function [parent=#TMXObjectGroup] getGroupName -- @param self -- @return string#string ret (return value: string) -------------------------------- -- @function [parent=#TMXObjectGroup] setProperties -- @param self -- @param #map_table map -------------------------------- -- @function [parent=#TMXObjectGroup] setObjects -- @param self -- @param #array_table array -------------------------------- -- @function [parent=#TMXObjectGroup] TMXObjectGroup -- @param self return nil
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/luarocks/persist.lua
15
6911
--- Utility module for loading files into tables and -- saving tables into files. -- Implemented separately to avoid interdependencies, -- as it is used in the bootstrapping stage of the cfg module. --module("luarocks.persist", package.seeall) local persist = {} package.loaded["luarocks.persist"] = persist local util = require("luarocks.util") --- Load and run a Lua file in an environment. -- @param filename string: the name of the file. -- @param env table: the environment table. -- @return (true, any) or (nil, string, string): true and the return value -- of the file, or nil, an error message and an error code ("open", "load" -- or "run") in case of errors. local function run_file(filename, env) local fd, err = io.open(filename) if not fd then return nil, err, "open" end local str, err = fd:read("*a") fd:close() if not str then return nil, err, "open" end str = str:gsub("^#![^\n]*\n", "") local chunk, ran if _VERSION == "Lua 5.1" then -- Lua 5.1 chunk, err = loadstring(str, filename) if chunk then setfenv(chunk, env) ran, err = pcall(chunk) end else -- Lua 5.2 chunk, err = load(str, filename, "t", env) if chunk then ran, err = pcall(chunk) end end if not chunk then return nil, "Error loading file: "..err, "load" end if not ran then return nil, "Error running file: "..err, "run" end return true, err end --- Load a Lua file containing assignments, storing them in a table. -- The global environment is not propagated to the loaded file. -- @param filename string: the name of the file. -- @param tbl table or nil: if given, this table is used to store -- loaded values. -- @return (table, table) or (nil, string, string): a table with the file's assignments -- as fields and set of undefined globals accessed in file, -- or nil, an error message and an error code ("open"; couldn't open the file, -- "load"; compile-time error, or "run"; run-time error) -- in case of errors. function persist.load_into_table(filename, tbl) assert(type(filename) == "string") assert(type(tbl) == "table" or not tbl) local result = tbl or {} local globals = {} local globals_mt = { __index = function(t, k) globals[k] = true end } local save_mt = getmetatable(result) setmetatable(result, globals_mt) local ok, err, errcode = run_file(filename, result) setmetatable(result, save_mt) if not ok then return nil, err, errcode end return result, globals end local write_table --- Write a value as Lua code. -- This function handles only numbers and strings, invoking write_table -- to write tables. -- @param out table or userdata: a writer object supporting :write() method. -- @param v: the value to be written. -- @param level number: the indentation level -- @param sub_order table: optional prioritization table -- @see write_table local function write_value(out, v, level, sub_order) if type(v) == "table" then write_table(out, v, level + 1, sub_order) elseif type(v) == "string" then if v:match("[\r\n]") then local open, close = "[[", "]]" local equals = 0 while v:find(close, 1, true) do equals = equals + 1 local eqs = ("="):rep(equals) open, close = "["..eqs.."[", "]"..eqs.."]" end out:write(open.."\n"..v..close) else out:write("\""..v:gsub("\\", "\\\\"):gsub("\"", "\\\"").."\"") end else out:write(tostring(v)) end end --- Write a table as Lua code in curly brackets notation to a writer object. -- Only numbers, strings and tables (containing numbers, strings -- or other recursively processed tables) are supported. -- @param out table or userdata: a writer object supporting :write() method. -- @param tbl table: the table to be written. -- @param level number: the indentation level -- @param field_order table: optional prioritization table write_table = function(out, tbl, level, field_order) out:write("{") local sep = "\n" local indentation = " " local indent = true local i = 1 for k, v, sub_order in util.sortedpairs(tbl, field_order) do out:write(sep) if indent then for n = 1,level do out:write(indentation) end end if k == i then i = i + 1 else if type(k) == "string" and k:match("^[a-zA-Z_][a-zA-Z0-9_]*$") then out:write(k) else out:write("[") write_value(out, k, level) out:write("]") end out:write(" = ") end write_value(out, v, level, sub_order) if type(k) == "number" then sep = ", " indent = false else sep = ",\n" indent = true end end if sep ~= "\n" then out:write("\n") for n = 1,level-1 do out:write(indentation) end end out:write("}") end --- Write a table as series of assignments to a writer object. -- @param out table or userdata: a writer object supporting :write() method. -- @param tbl table: the table to be written. -- @param field_order table: optional prioritization table local function write_table_as_assignments(out, tbl, field_order) for k, v, sub_order in util.sortedpairs(tbl, field_order) do out:write(k.." = ") write_value(out, v, 0, sub_order) out:write("\n") end end --- Save the contents of a table to a string. -- Each element of the table is saved as a global assignment. -- Only numbers, strings and tables (containing numbers, strings -- or other recursively processed tables) are supported. -- @param tbl table: the table containing the data to be written -- @param field_order table: an optional array indicating the order of top-level fields. -- @return string function persist.save_from_table_to_string(tbl, field_order) local out = {buffer = {}} function out:write(data) table.insert(self.buffer, data) end write_table_as_assignments(out, tbl, field_order) return table.concat(out.buffer) end --- Save the contents of a table in a file. -- Each element of the table is saved as a global assignment. -- Only numbers, strings and tables (containing numbers, strings -- or other recursively processed tables) are supported. -- @param filename string: the output filename -- @param tbl table: the table containing the data to be written -- @param field_order table: an optional array indicating the order of top-level fields. -- @return boolean or (nil, string): true if successful, or nil and a -- message in case of errors. function persist.save_from_table(filename, tbl, field_order) local out = io.open(filename, "w") if not out then return nil, "Cannot create file at "..filename end write_table_as_assignments(out, tbl, field_order) out:close() return true end return persist
mit
EliHar/Pattern_recognition
torch1/extra/cudnn/convert.lua
1
1741
-- modules that can be converted to nn seamlessly local layer_list = { 'BatchNormalization', 'SpatialBatchNormalization', 'SpatialConvolution', 'SpatialCrossMapLRN', 'SpatialFullConvolution', 'SpatialMaxPooling', 'SpatialAveragePooling', 'ReLU', 'Tanh', 'Sigmoid', 'SoftMax', 'LogSoftMax', 'VolumetricBatchNormalization', 'VolumetricConvolution', 'VolumetricMaxPooling', 'VolumetricAveragePooling', } -- goes over a given net and converts all layers to dst backend -- for example: net = cudnn.convert(net, cudnn) function cudnn.convert(net, dst, exclusion_fn) return net:replace(function(x) local y = 0 local src = dst == nn and cudnn or nn local src_prefix = src == nn and 'nn.' or 'cudnn.' local dst_prefix = dst == nn and 'nn.' or 'cudnn.' local function convert(v) local y = {} torch.setmetatable(y, dst_prefix..v) if v == 'ReLU' then y = dst.ReLU() end -- because parameters for k,u in pairs(x) do y[k] = u end if src == cudnn and x.clearDesc then x.clearDesc(y) end if src == cudnn and v == 'SpatialAveragePooling' then y.divide = true y.count_include_pad = v.mode == 'CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING' end return y end if exclusion_fn and exclusion_fn(x) then return x end local t = torch.typename(x) if t == 'nn.SpatialConvolutionMM' then y = convert('SpatialConvolution') elseif t == 'inn.SpatialCrossResponseNormalization' then y = convert('SpatialCrossMapLRN') else for i,v in ipairs(layer_list) do if torch.typename(x) == src_prefix..v then y = convert(v) end end end return y == 0 and x or y end) end
mit
Jennal/cocos2dx-3.2-qt
tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua
14
16145
local kMaxNodes = 50000 local kBasicZOrder = 10 local kNodesIncrease = 250 local TEST_COUNT = 7 local s = cc.Director:getInstance():getWinSize() ----------------------------------- -- For test functions ----------------------------------- local function performanceActions(sprite) sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 local rot = cc.RotateBy:create(period, 360.0 * math.random()) local rot = cc.RotateBy:create(period, 360.0 * math.random()) local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceActions20(sprite) if math.random() < 0.2 then sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else sprite:setPosition(cc.p(-1000, -1000)) end local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 local rot = cc.RotateBy:create(period, 360.0 * math.random()) local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceRotationScale(sprite) sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setRotation(math.random() * 360) sprite:setScale(math.random() * 2) end local function performancePosition(sprite) sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) end local function performanceout20(sprite) if math.random() < 0.2 then sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else sprite:setPosition(cc.p(-1000, -1000)) end end local function performanceOut100(sprite) sprite:setPosition(cc.p( -1000, -1000)) end local function performanceScale(sprite) sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setScale(math.random() * 100 / 50) end ----------------------------------- -- Subtest ----------------------------------- local subtestNumber = 1 local batchNode = nil -- cc.SpriteBatchNode local parent = nil -- cc.Node local function initWithSubTest(nSubTest, p) subtestNumber = nSubTest parent = p batchNode = nil local mgr = cc.Director:getInstance():getTextureCache() -- remove all texture mgr:removeTexture(mgr:addImage("Images/grossinis_sister1.png")) mgr:removeTexture(mgr:addImage("Images/grossini_dance_atlas.png")) mgr:removeTexture(mgr:addImage("Images/spritesheet1.png")) if subtestNumber == 2 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 3 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 5 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 6 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 8 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 9 then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) end -- todo if batchNode ~= nil then batchNode:retain() end cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) end local function createSpriteWithTag(tag) cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) local sprite = nil if subtestNumber == 1 then sprite = cc.Sprite:create("Images/grossinis_sister1.png") parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 2 then sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 3 then sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 4 then local idx = math.floor((math.random() * 1400 / 100)) + 1 local num if idx < 10 then num = "0" .. idx else num = idx end local str = "Images/grossini_dance_" .. num .. ".png" sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 5 then local y, x local r = math.floor(math.random() * 1400 / 100) y = math.floor(r / 5) x = math.mod(r, 5) x = x * 85 y = y * 121 sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 6 then local y, x local r = math.floor(math.random() * 1400 / 100) y = math.floor(r / 5) x = math.mod(r, 5) x = x * 85 y = y * 121 sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 7 then local y, x local r = math.floor(math.random() * 6400 / 100) y = math.floor(r / 8) x = math.mod(r, 8) local str = "Images/sprites_test/sprite-"..x.."-"..y..".png" sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 8 then local y, x local r = math.floor(math.random() * 6400 / 100) y = math.floor(r / 8) x = math.mod(r, 8) x = x * 32 y = y * 32 sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 9 then local y, x local r = math.floor(math.random() * 6400 / 100) y = math.floor(r / 8) x = math.mod(r, 8) x = x * 32 y = y * 32 sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) end cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) return sprite end local function removeByTag(tag) if subtestNumber == 1 then parent:removeChildByTag(tag + 100, true) elseif subtestNumber == 4 then parent:removeChildByTag(tag + 100, true) elseif subtestNumber == 7 then parent:removeChildByTag(tag + 100, true) else batchNode:removeChildAtIndex(tag, true) end end ----------------------------------- -- PerformBasicLayer ----------------------------------- local curCase = 0 local maxCases = 7 local function showThisTest() local scene = CreateSpriteTestScene() cc.Director:getInstance():replaceScene(scene) end local function backCallback(sender) subtestNumber = 1 curCase = curCase - 1 if curCase < 0 then curCase = curCase + maxCases end showThisTest() end local function restartCallback(sender) subtestNumber = 1 showThisTest() end local function nextCallback(sender) subtestNumber = 1 curCase = curCase + 1 curCase = math.mod(curCase, maxCases) showThisTest() end local function toPerformanceMainLayer(sender) cc.Director:getInstance():replaceScene(PerformanceTest()) end local function initWithLayer(layer, controlMenuVisible) cc.MenuItemFont:setFontName("Arial") cc.MenuItemFont:setFontSize(24) local mainItem = cc.MenuItemFont:create("Back") mainItem:registerScriptTapHandler(toPerformanceMainLayer) mainItem:setPosition(s.width - 50, 25) local menu = cc.Menu:create() menu:addChild(mainItem) menu:setPosition(cc.p(0, 0)) if controlMenuVisible == true then local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) item1:setPosition(s.width / 2 - 100, 30) item2:setPosition(s.width / 2, 30) item3:setPosition(s.width / 2 + 100, 30) menu:addChild(item1, kItemTagBasic) menu:addChild(item2, kItemTagBasic) menu:addChild(item3, kItemTagBasic) end layer:addChild(menu) end ----------------------------------- -- SpriteMainScene ----------------------------------- local lastRenderedCount = nil local quantityNodes = nil local infoLabel = nil local titleLabel = nil local function testNCallback(tag) subtestNumber = tag - kBasicZOrder showThisTest() end local function updateNodes() if quantityNodes ~= lastRenderedCount then local str = quantityNodes .. " nodes" infoLabel:setString(str) lastRenderedCount = quantityNodes end end local function onDecrease(sender) if quantityNodes <= 0 then return end for i = 0, kNodesIncrease - 1 do quantityNodes = quantityNodes - 1 removeByTag(quantityNodes) end updateNodes() end local function onIncrease(sender) if quantityNodes >= kMaxNodes then return end for i = 0, kNodesIncrease - 1 do local sprite = createSpriteWithTag(quantityNodes) if curCase == 0 then doPerformSpriteTest1(sprite) elseif curCase == 1 then doPerformSpriteTest2(sprite) elseif curCase == 2 then doPerformSpriteTest3(sprite) elseif curCase == 3 then doPerformSpriteTest4(sprite) elseif curCase == 4 then doPerformSpriteTest5(sprite) elseif curCase == 5 then doPerformSpriteTest6(sprite) elseif curCase == 6 then doPerformSpriteTest7(sprite) end quantityNodes = quantityNodes + 1 end updateNodes() end local function initWithMainTest(scene, asubtest, nNodes) subtestNumber = asubtest initWithSubTest(asubtest, scene) lastRenderedCount = 0 quantityNodes = 0 cc.MenuItemFont:setFontSize(65) local decrease = cc.MenuItemFont:create(" - ") decrease:registerScriptTapHandler(onDecrease) decrease:setColor(cc.c3b(0, 200, 20)) local increase = cc.MenuItemFont:create(" + ") increase:registerScriptTapHandler(onIncrease) increase:setColor(cc.c3b(0, 200, 20)) local menu = cc.Menu:create() menu:addChild(decrease) menu:addChild(increase) menu:alignItemsHorizontally() menu:setPosition(s.width / 2, s.height - 65) scene:addChild(menu, 1) infoLabel = cc.Label:createWithTTF("0 nodes", s_markerFeltFontPath, 30) infoLabel:setColor(cc.c3b(0, 200, 20)) infoLabel:setAnchorPoint(cc.p(0.5, 0.5)) infoLabel:setPosition(s.width / 2, s.height - 90) scene:addChild(infoLabel, 1) maxCases = TEST_COUNT -- Sub Tests cc.MenuItemFont:setFontSize(32) subMenu = cc.Menu:create() for i = 1, 9 do local str = i .. " " local itemFont = cc.MenuItemFont:create(str) itemFont:registerScriptTapHandler(testNCallback) --itemFont:setTag(i) subMenu:addChild(itemFont, kBasicZOrder + i, kBasicZOrder + i) if i <= 3 then itemFont:setColor(cc.c3b(200, 20, 20)) elseif i <= 6 then itemFont:setColor(cc.c3b(0, 200, 20)) else itemFont:setColor(cc.c3b(0, 20, 200)) end end subMenu:alignItemsHorizontally() subMenu:setPosition(cc.p(s.width / 2, 80)) scene:addChild(subMenu, 1) -- add title label titleLabel = cc.Label:createWithTTF("No title", s_arialPath, 40) scene:addChild(titleLabel, 1) titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 32) titleLabel:setColor(cc.c3b(255, 255, 40)) while quantityNodes < nNodes do onIncrease() end end ----------------------------------- -- SpritePerformTest1 ----------------------------------- function doPerformSpriteTest1(sprite) performancePosition(sprite) end local function SpriteTestLayer1() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "A (" .. subtestNumber .. ") position" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest2 ----------------------------------- function doPerformSpriteTest2(sprite) performanceScale(sprite) end local function SpriteTestLayer2() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "B (" .. subtestNumber .. ") scale" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest3 ----------------------------------- function doPerformSpriteTest3(sprite) performanceRotationScale(sprite) end local function SpriteTestLayer3() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "C (" .. subtestNumber .. ") scale + rot" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest4 ----------------------------------- function doPerformSpriteTest4(sprite) performanceOut100(sprite) end local function SpriteTestLayer4() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "D (" .. subtestNumber .. ") 100% out" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest5 ----------------------------------- function doPerformSpriteTest5(sprite) performanceout20(sprite) end local function SpriteTestLayer5() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "E (" .. subtestNumber .. ") 80% out" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest6 ----------------------------------- function doPerformSpriteTest6(sprite) performanceActions(sprite) end local function SpriteTestLayer6() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "F (" .. subtestNumber .. ") actions" titleLabel:setString(str) return layer end ----------------------------------- -- SpritePerformTest7 ----------------------------------- function doPerformSpriteTest7(sprite) performanceActions20(sprite) end local function SpriteTestLayer7() local layer = cc.Layer:create() initWithLayer(layer, true) local str = "G (" .. subtestNumber .. ") actions 80% out" titleLabel:setString(str) return layer end ----------------------------------- -- PerformanceSpriteTest ----------------------------------- function CreateSpriteTestScene() local scene = cc.Scene:create() initWithMainTest(scene, subtestNumber, kNodesIncrease) if curCase == 0 then scene:addChild(SpriteTestLayer1()) elseif curCase == 1 then scene:addChild(SpriteTestLayer2()) elseif curCase == 2 then scene:addChild(SpriteTestLayer3()) elseif curCase == 3 then scene:addChild(SpriteTestLayer4()) elseif curCase == 4 then scene:addChild(SpriteTestLayer5()) elseif curCase == 5 then scene:addChild(SpriteTestLayer6()) elseif curCase == 6 then scene:addChild(SpriteTestLayer7()) end return scene end function PerformanceSpriteTest() curCase = 0 return CreateSpriteTestScene() end
mit
avdimdv/proxmark3
client/lualibs/read14a.lua
4
4250
--[[ This is a library to read 14443a tags. It can be used something like this local reader = require('read14a') result, err = reader.read1443a() if not result then print(err) return end print(result.name) --]] -- Loads the commands-library local cmds = require('commands') local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds local ISO14A_COMMAND = { ISO14A_CONNECT = 1, ISO14A_NO_DISCONNECT = 2, ISO14A_APDU = 4, ISO14A_RAW = 8, ISO14A_REQUEST_TRIGGER = 0x10, ISO14A_APPEND_CRC = 0x20, ISO14A_SET_TIMEOUT = 0x40, ISO14A_NO_SELECT = 0x80, ISO14A_TOPAZMODE = 0x100 } local ISO14443a_TYPES = {} ISO14443a_TYPES[0x00] = "NXP MIFARE Ultralight | Ultralight C" ISO14443a_TYPES[0x01] = "NXP MIFARE TNP3xxx Activision Game Appliance" ISO14443a_TYPES[0x04] = "NXP MIFARE (various !DESFire !DESFire EV1)" ISO14443a_TYPES[0x08] = "NXP MIFARE CLASSIC 1k | Plus 2k" ISO14443a_TYPES[0x09] = "NXP MIFARE Mini 0.3k" ISO14443a_TYPES[0x10] = "NXP MIFARE Plus 2k" ISO14443a_TYPES[0x11] = "NXP MIFARE Plus 4k" ISO14443a_TYPES[0x18] = "NXP MIFARE Classic 4k | Plus 4k" ISO14443a_TYPES[0x20] = "NXP MIFARE DESFire 4k | DESFire EV1 2k/4k/8k | Plus 2k/4k | JCOP 31/41" ISO14443a_TYPES[0x24] = "NXP MIFARE DESFire | DESFire EV1" ISO14443a_TYPES[0x28] = "JCOP31 or JCOP41 v2.3.1" ISO14443a_TYPES[0x38] = "Nokia 6212 or 6131 MIFARE CLASSIC 4K" ISO14443a_TYPES[0x88] = "Infineon MIFARE CLASSIC 1K" ISO14443a_TYPES[0x98] = "Gemplus MPCOS" local function tostring_1443a(sak) return ISO14443a_TYPES[sak] or ("Unknown (SAK=%x)"):format(sak) end local function parse1443a(data) --[[ Based on this struct : typedef struct { byte_t uid[10]; byte_t uidlen; byte_t atqa[2]; byte_t sak; byte_t ats_len; byte_t ats[256]; } __attribute__((__packed__)) iso14a_card_select_t; --]] local count,uid,uidlen, atqa, sak, ats_len, ats= bin.unpack('H10CH2CC',data) uid = uid:sub(1,2*uidlen) --print("uid, atqa, sak: ",uid, atqa, sak) --print("TYPE: ", tostring_1443a(sak)) return { uid = uid, atqa = atqa, sak = sak, name = tostring_1443a(sak)} end --- Sends a USBpacket to the device -- @param command - the usb packet to send -- @param ignoreresponse - if set to true, we don't read the device answer packet -- which is usually recipe for fail. If not sent, the host will wait 2s for a -- response of type CMD_ACK -- @return packet,nil if successfull -- nil, errormessage if unsuccessfull local function sendToDevice(command, ignoreresponse) core.clearCommandBuffer() local err = core.SendCommand(command:getBytes()) if err then print(err) return nil, err end if ignoreresponse then return nil,nil end local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT) return response,nil end -- This function does a connect and retrieves som einfo -- @param dont_disconnect - if true, does not disable the field -- @return if successfull: an table containing card info -- @return if unsuccessfull : nil, error local function read14443a(dont_disconnect) local command, result, info, err, data command = Command:new{cmd = cmds.CMD_READER_ISO_14443a, arg1 = ISO14A_COMMAND.ISO14A_CONNECT} if dont_disconnect then command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_DISCONNECT end local result,err = sendToDevice(command) if result then local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result) if arg0 == 0 then return nil, "iso14443a card select failed" end data = string.sub(result,count) info, err = parse1443a(data) else err ="No response from card" end if err then print(err) return nil, err end return info end --- -- Waits for a mifare card to be placed within the vicinity of the reader. -- @return if successfull: an table containing card info -- @return if unsuccessfull : nil, error local function waitFor14443a() print("Waiting for card... press any key to quit") while not core.ukbhit() do res, err = read14443a() if res then return res end -- err means that there was no response from card end return nil, "Aborted by user" end local library = { read1443a = read14443a, read = read14443a, waitFor14443a = waitFor14443a, parse1443a = parse1443a, sendToDevice = sendToDevice, ISO14A_COMMAND = ISO14A_COMMAND, } return library
gpl-2.0
Jennal/cocos2dx-3.2-qt
cocos/scripting/lua-bindings/auto/api/PhysicsJointRotarySpring.lua
7
1400
-------------------------------- -- @module PhysicsJointRotarySpring -- @extend PhysicsJoint -- @parent_module cc -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] getDamping -- @param self -- @return float#float ret (return value: float) -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] setRestAngle -- @param self -- @param #float float -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] getStiffness -- @param self -- @return float#float ret (return value: float) -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] setStiffness -- @param self -- @param #float float -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] setDamping -- @param self -- @param #float float -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] getRestAngle -- @param self -- @return float#float ret (return value: float) -------------------------------- -- @function [parent=#PhysicsJointRotarySpring] construct -- @param self -- @param #cc.PhysicsBody physicsbody -- @param #cc.PhysicsBody physicsbody -- @param #float float -- @param #float float -- @return PhysicsJointRotarySpring#PhysicsJointRotarySpring ret (return value: cc.PhysicsJointRotarySpring) return nil
mit
yangboz/bugfree-bugfixes
CocosJSGame/frameworks/js-bindings/cocos2d-x/cocos/scripting/lua-bindings/script/bitExtend.lua
14
1614
-- bit operation bit = bit or {} bit.data32 = {} for i=1,32 do bit.data32[i]=2^(32-i) end function bit._b2d(arg) local nr=0 for i=1,32 do if arg[i] ==1 then nr=nr+bit.data32[i] end end return nr end function bit._d2b(arg) arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1) local tr={} for i=1,32 do if arg >= bit.data32[i] then tr[i]=1 arg=arg-bit.data32[i] else tr[i]=0 end end return tr end function bit._and(a,b) local op1=bit._d2b(a) local op2=bit._d2b(b) local r={} for i=1,32 do if op1[i]==1 and op2[i]==1 then r[i]=1 else r[i]=0 end end return bit._b2d(r) end function bit._rshift(a,n) local op1=bit._d2b(a) n = n <= 32 and n or 32 n = n >= 0 and n or 0 for i=32, n+1, -1 do op1[i] = op1[i-n] end for i=1, n do op1[i] = 0 end return bit._b2d(op1) end function bit._not(a) local op1=bit._d2b(a) local r={} for i=1,32 do if op1[i]==1 then r[i]=0 else r[i]=1 end end return bit._b2d(r) end function bit._or(a,b) local op1=bit._d2b(a) local op2=bit._d2b(b) local r={} for i=1,32 do if op1[i]==1 or op2[i]==1 then r[i]=1 else r[i]=0 end end return bit._b2d(r) end bit.band = bit.band or bit._and bit.rshift = bit.rshift or bit._rshift bit.bnot = bit.bnot or bit._not
mit
rlcevg/Zero-K
LuaRules/Configs/MetalSpots/SpringMountainDelta.lua
17
4246
return { spots = { {x = 7368, z = 5688, metal = 1.8013601303101}, {x = 3000, z = 3240, metal = 1.4149597883224}, {x = 4600, z = 7416, metal = 1.4151902198792}, {x = 4744, z = 2728, metal = 1.4163403511047}, {x = 6312, z = 2536, metal = 1.4163397550583}, {x = 3992, z = 5352, metal = 1.4165700674057}, {x = 4216, z = 5832, metal = 0.98279017210007}, {x = 4232, z = 4360, metal = 1.4131203889847}, {x = 1688, z = 1928, metal = 1.7999800443649}, {x = 4696, z = 3432, metal = 1.4142698049545}, {x = 1240, z = 4808, metal = 0.98371005058289}, {x = 6952, z = 7848, metal = 1.801589846611}, {x = 4088, z = 152, metal = 0.98371005058289}, {x = 1256, z = 6808, metal = 1.7992898225784}, {x = 4616, z = 6792, metal = 0.98394012451172}, {x = 6552, z = 8120, metal = 1.733970284462}, {x = 7416, z = 5288, metal = 1.8013601303101}, {x = 2552, z = 280, metal = 1.8029699325562}, {x = 8056, z = 2088, metal = 0.98417007923126}, {x = 8024, z = 1192, metal = 1.415189743042}, {x = 6296, z = 5928, metal = 1.8011299371719}, {x = 8104, z = 7256, metal = 1.7949198484421}, {x = 2136, z = 3416, metal = 0.98302000761032}, {x = 248, z = 2632, metal = 1.802970290184}, {x = 568, z = 5752, metal = 1.4161102771759}, {x = 3256, z = 3432, metal = 1.4142700433731}, {x = 7144, z = 2904, metal = 1.4154199361801}, {x = 5080, z = 2392, metal = 1.8009005784988}, {x = 1528, z = 7064, metal = 1.7995201349258}, {x = 7640, z = 7240, metal = 1.8006699085236}, {x = 552, z = 1384, metal = 1.8018201589584}, {x = 3640, z = 4840, metal = 1.7999802827835}, {x = 6968, z = 1992, metal = 1.4144995212555}, {x = 4872, z = 7768, metal = 1.4154200553894}, {x = 328, z = 3160, metal = 0.98463010787964}, {x = 6024, z = 856, metal = 1.4163397550583}, {x = 3880, z = 1288, metal = 1.4135800600052}, {x = 5384, z = 7528, metal = 1.8022797107697}, {x = 7192, z = 3688, metal = 1.4124299287796}, {x = 6424, z = 1432, metal = 1.7988300323486}, {x = 1032, z = 200, metal = 1.7999802827835}, {x = 5528, z = 2744, metal = 1.8020503520966}, {x = 216, z = 1512, metal = 1.8011299371719}, {x = 5144, z = 3112, metal = 1.415189743042}, {x = 3080, z = 6600, metal = 0.98416990041733}, {x = 1944, z = 6344, metal = 1.8004401922226}, {x = 5304, z = 7912, metal = 1.8032004833221}, {x = 5576, z = 7784, metal = 1.8013603687286}, {x = 7224, z = 8024, metal = 1.7997500896454}, {x = 280, z = 7448, metal = 1.4163397550583}, {x = 2200, z = 7272, metal = 0.98370999097824}, {x = 5848, z = 152, metal = 0.98417013883591}, {x = 1480, z = 1608, metal = 1.8020497560501}, {x = 8072, z = 3656, metal = 0.98440003395081}, {x = 2456, z = 7048, metal = 1.4138096570969}, {x = 7224, z = 1048, metal = 1.7990598678589}, {x = 7864, z = 6984, metal = 1.7999800443649}, {x = 888, z = 5752, metal = 0.98394000530243}, {x = 4280, z = 3032, metal = 1.4140399694443}, {x = 3688, z = 5192, metal = 1.416109919548}, {x = 4664, z = 968, metal = 1.4151901006699}, {x = 5992, z = 6040, metal = 1.7999798059464}, {x = 360, z = 3560, metal = 1.4154199361801}, {x = 1144, z = 7208, metal = 0.98049008846283}, {x = 7672, z = 5512, metal = 1.8025101423264}, {x = 1832, z = 1496, metal = 1.8002097606659}, {x = 2680, z = 792, metal = 1.8025106191635}, {x = 1016, z = 584, metal = 1.8011300563812}, {x = 6152, z = 5688, metal = 1.8020499944687}, {x = 936, z = 7992, metal = 1.4147298336029}, {x = 2264, z = 3944, metal = 1.4138095378876}, {x = 104, z = 3752, metal = 1.4149601459503}, {x = 5736, z = 1976, metal = 1.800669670105}, {x = 2264, z = 5720, metal = 1.8011300563812}, {x = 2328, z = 4328, metal = 1.4151899814606}, {x = 1592, z = 408, metal = 1.8013601303101}, {x = 5320, z = 1320, metal = 1.4156502485275}, {x = 4056, z = 4072, metal = 1.4124298095703}, {x = 2792, z = 4056, metal = 1.8008999824524}, {x = 7960, z = 216, metal = 1.8025100231171}, {x = 2792, z = 520, metal = 1.8022797107697}, {x = 5432, z = 3736, metal = 0.98417007923126}, {x = 328, z = 1208, metal = 1.8025102615356}, {x = 3960, z = 2360, metal = 0.98347997665405}, {x = 7000, z = 248, metal = 1.4140399694443}, {x = 441, z = 2424, metal = 1.8}, {x = 574, z = 2548, metal = 1.8}, } }
gpl-2.0
Amadiro/obtuse-tanuki
libs/winapi/bitmap.lua
2
6375
--proc/gdi/bitmap: windows bitmap API (submodule required by gdi). --Written by Cosmin Apreutesei. Public Domain. setfenv(1, require'winapi') --constants for the biCompression field BI_RGB = 0 BI_RLE8 = 1 BI_RLE4 = 2 BI_BITFIELDS = 3 BI_JPEG = 4 BI_PNG = 5 DIB_RGB_COLORS = 0 DIB_PAL_COLORS = 1 local function U(s) return ffi.cast('uint32_t*', ffi.cast('const char*', s))[0] end LCS_sRGB = U'sRGB' LCS_WINDOWS_COLOR_SPACE = U'Win ' LCS_CALIBRATED_RGB = 0x00000000 LCS_GM_BUSINESS = 0x00000001 LCS_GM_GRAPHICS = 0x00000002 LCS_GM_IMAGES = 0x00000004 LCS_GM_ABS_COLORIMETRIC = 0x00000008 ffi.cdef[[ typedef struct tagRGBQUAD { BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; } RGBQUAD; typedef long FXPT2DOT30, *LPFXPT2DOT30; typedef struct tagCIEXYZ { FXPT2DOT30 ciexyzX; FXPT2DOT30 ciexyzY; FXPT2DOT30 ciexyzZ; } CIEXYZ, *LPCIEXYZ; typedef struct tagICEXYZTRIPLE { CIEXYZ ciexyzRed; CIEXYZ ciexyzGreen; CIEXYZ ciexyzBlue; } CIEXYZTRIPLE, *LPCIEXYZTRIPLE; typedef struct tagBITMAP { LONG bmType; LONG bmWidth; LONG bmHeight; LONG bmWidthBytes; WORD bmPlanes; WORD bmBitsPixel; LPVOID bmBits; } BITMAP, *PBITMAP; typedef struct tagBITMAPINFOHEADER{ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER, *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER; typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO, *LPBITMAPINFO, *PBITMAPINFO; typedef struct { DWORD bV4Size; LONG bV4Width; LONG bV4Height; WORD bV4Planes; WORD bV4BitCount; DWORD bV4V4Compression; DWORD bV4SizeImage; LONG bV4XPelsPerMeter; LONG bV4YPelsPerMeter; DWORD bV4ClrUsed; DWORD bV4ClrImportant; DWORD bV4RedMask; DWORD bV4GreenMask; DWORD bV4BlueMask; DWORD bV4AlphaMask; DWORD bV4CSType; CIEXYZTRIPLE bV4Endpoints; DWORD bV4GammaRed; DWORD bV4GammaGreen; DWORD bV4GammaBlue; } BITMAPV4HEADER, *LPBITMAPV4HEADER, *PBITMAPV4HEADER; typedef struct { DWORD bV5Size; LONG bV5Width; LONG bV5Height; WORD bV5Planes; WORD bV5BitCount; DWORD bV5Compression; DWORD bV5SizeImage; LONG bV5XPelsPerMeter; LONG bV5YPelsPerMeter; DWORD bV5ClrUsed; DWORD bV5ClrImportant; DWORD bV5RedMask; DWORD bV5GreenMask; DWORD bV5BlueMask; DWORD bV5AlphaMask; DWORD bV5CSType; CIEXYZTRIPLE bV5Endpoints; DWORD bV5GammaRed; DWORD bV5GammaGreen; DWORD bV5GammaBlue; DWORD bV5Intent; DWORD bV5ProfileData; DWORD bV5ProfileSize; DWORD bV5Reserved; } BITMAPV5HEADER, *LPBITMAPV5HEADER, *PBITMAPV5HEADER; HBITMAP CreateBitmap(int nWidth, int nHeight, UINT cPlanes, UINT cBitsPerPel, const VOID *lpvBits); HBITMAP CreateCompatibleBitmap(HDC hdc, int cx, int cy); COLORREF SetPixel(HDC hdc, int x, int y, COLORREF color); HBITMAP CreateDIBSection(HDC hdc, const BITMAPINFO *lpbmi, UINT usage, void **ppvBits, HANDLE hSection, DWORD offset); BOOL BitBlt(HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop); int GetDIBits(HDC hdc, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbi, UINT uUsage); ]] BITMAPINFOHEADER = struct{ctype = 'BITMAPINFOHEADER', size = 'biSize'} BITMAPV4HEADER = struct{ctype = 'BITMAPV4HEADER', size = 'bV4Size'} BITMAPV5HEADER = struct{ctype = 'BITMAPV5HEADER', size = 'bV5Size'} function CreateBitmap(w, h, planes, bpp, bits) return checkh(C.CreateBitmap(w, h, planes, bpp, bits)) end function CreateCompatibleBitmap(hdc, w, h) return checkh(C.CreateCompatibleBitmap(hdc, w, h)) end function CreateDIBSection(hdc, bmi, usage, hSection, offset, bits) local bits = bits or ffi.new'void*[1]' local hbitmap = checkh(C.CreateDIBSection(hdc, bmi, usage, bits, hSection, offset or 0)) return hbitmap, bits[0] end function SetPixel(hdc, x, y, color) return C.SetPixel(hdc, x, y, color) --TODO: checkclr end R2_BLACK = 1 -- 0 R2_NOTMERGEPEN = 2 -- DPon R2_MASKNOTPEN = 3 -- DPna R2_NOTCOPYPEN = 4 -- PN R2_MASKPENNOT = 5 -- PDna R2_NOT = 6 -- Dn R2_XORPEN = 7 -- DPx R2_NOTMASKPEN = 8 -- DPan R2_MASKPEN = 9 -- DPa R2_NOTXORPEN = 10 -- DPxn R2_NOP = 11 -- D R2_MERGENOTPEN = 12 -- DPno R2_COPYPEN = 13 -- P R2_MERGEPENNOT = 14 -- PDno R2_MERGEPEN = 15 -- DPo R2_WHITE = 16 -- 1 R2_LAST = 16 SRCCOPY = 0x00CC0020 -- dest = source SRCPAINT = 0x00EE0086 -- dest = source OR dest SRCAND = 0x008800C6 -- dest = source AND dest SRCINVERT = 0x00660046 -- dest = source XOR dest SRCERASE = 0x00440328 -- dest = source AND (NOT dest ) NOTSRCCOPY = 0x00330008 -- dest = (NOT source) NOTSRCERASE = 0x001100A6 -- dest = (NOT src) AND (NOT dest) MERGECOPY = 0x00C000CA -- dest = (source AND pattern) MERGEPAINT = 0x00BB0226 -- dest = (NOT source) OR dest PATCOPY = 0x00F00021 -- dest = pattern PATPAINT = 0x00FB0A09 -- dest = DPSnoo PATINVERT = 0x005A0049 -- dest = pattern XOR dest DSTINVERT = 0x00550009 -- dest = (NOT dest) BLACKNESS = 0x00000042 -- dest = BLACK WHITENESS = 0x00FF0062 -- dest = WHITE NOMIRRORBITMAP = 0x80000000 -- Do not Mirror the bitmap in this call CAPTUREBLT = 0x40000000 -- Include layered windows function MAKEROP4(fore,back) return bit.bor(bit.band(bit.lshift(back, 8), 0xFF000000), fore) end function BitBlt(dst, x, y, w, h, src, x1, y1, rop) return checknz(C.BitBlt(dst, x, y, w, h, src, x1, y1, flags(rop))) end function GetDIBits(hdc, hbmp, firstrow, rowcount, buf, info, usage) return checknz(C.GetDIBits(hdc, hbmp, firstrow, rowcount, buf, info, flags(usage))) end
mit
rlcevg/Zero-K
LuaUI/Widgets/chili/Handlers/skinhandler.lua
16
4757
--//============================================================================= --// Theme SkinHandler = {} --//============================================================================= --// load shared skin utils local SkinUtilsEnv = {} setmetatable(SkinUtilsEnv,{__index = getfenv()}) VFS.Include(CHILI_DIRNAME .. "headers/skinutils.lua", SkinUtilsEnv) --//============================================================================= --// translates the skin's FileNames to the correct FilePaths --// (skins just define the name not the path!) local function SplitImageOptions(str) local options, str2 = str:match "^(:.*:)(.*)" if (options) then return options, str2 else return "", str end end local function TranslateFilePaths(skinConfig, dirs) for i,v in pairs(skinConfig) do if (i == "info") then --// nothing elseif istable(v) then TranslateFilePaths(v, dirs) elseif isstring(v) then local opt, fileName = SplitImageOptions(v) for _,dir in ipairs(dirs) do local filePath = dir .. fileName if VFS.FileExists(filePath) then skinConfig[i] = opt .. filePath break end end end end end --//============================================================================= --// load all skins knownSkins = {} SkinHandler.knownSkins = knownSkins local n = 1 local skinDirs = VFS.SubDirs(SKIN_DIRNAME , "*", VFS.RAW_FIRST) for i,dir in ipairs(skinDirs) do local skinCfgFile = dir .. 'skin.lua' if (VFS.FileExists(skinCfgFile, VFS.RAW_FIRST)) then --// use a custom enviroment (safety + auto loads skin utils) local senv = {SKINDIR = dir} setmetatable(senv,{__index = SkinUtilsEnv}) --// load the skin local skinConfig = VFS.Include(skinCfgFile,senv, VFS.RAW_FIRST) if (skinConfig)and(type(skinConfig)=="table")and(type(skinConfig.info)=="table") then skinConfig.info.dir = dir SkinHandler.knownSkins[n] = skinConfig SkinHandler.knownSkins[skinConfig.info.name:lower()] = skinConfig n = n + 1 end end end --//FIXME handle multiple-dependencies correctly! (atm it just works with 1 level!) --// translate filepaths and handle dependencies for i,skinConfig in ipairs(SkinHandler.knownSkins) do local dirs = { skinConfig.info.dir } --// translate skinName -> skinDir and remove broken dependencies local brokenDependencies = {} for i,dependSkinName in ipairs(skinConfig.info.depend or {}) do local dependSkin = SkinHandler.knownSkins[dependSkinName:lower()] if (dependSkin) then dirs[#dirs+1] = dependSkin.info.dir table.merge(skinConfig, dependSkin) else Spring.Echo("Chili: Skin " .. skinConfig.info.name .. " depends on an unknown skin named " .. dependSkinName .. ".") end end --// add the default skindir to the end dirs[#dirs+1] = SKIN_DIRNAME .. 'default/' --// finally translate all paths TranslateFilePaths(skinConfig, dirs) end --//============================================================================= --// Internal local function GetSkin(skinname) return SkinHandler.knownSkins[tostring(skinname):lower()] end SkinHandler.defaultSkin = GetSkin('default') --//============================================================================= --// API function SkinHandler.IsValidSkin(skinname) return (not not GetSkin(skinname)) end function SkinHandler.GetSkinInfo() local sk = GetSkin(skinname) if (sk) then return table.shallowcopy(sk.info) end return {} end function SkinHandler.GetAvailableSkins() local skins = {} local knownSkins = SkinHandler.knownSkins for i=1,#knownSkins do skins[i] = knownSkins[i].info.name end return skins end local function MergeProperties(obj, skin, classname) local skinclass = skin[classname] if not skinclass then return end BackwardCompa(skinclass) table.merge(obj, skinclass) MergeProperties(obj, skin, skinclass.clone) end function SkinHandler.LoadSkin(control, class) local skin = GetSkin(control.skinName) local defskin = SkinHandler.defaultSkin local found = false local inherited = class.inherited local classname = control.classname repeat --FIXME scan whole `depend` table if (skin) then --if (skin[classname]) then MergeProperties(control, skin, classname) -- per-class defaults MergeProperties(control, skin, "general") if (skin[classname]) then found = true end end if (defskin[classname]) then MergeProperties(control, defskin, classname) -- per-class defaults MergeProperties(control, defskin, "general") found = true end if inherited then classname = inherited.classname inherited = inherited.inherited else found = true end until (found) end
gpl-2.0
lynx-seu/skynet
service/multicastd.lua
47
5408
local skynet = require "skynet" local mc = require "multicast.core" local datacenter = require "datacenter" local harbor_id = skynet.harbor(skynet.self()) local command = {} local channel = {} local channel_n = {} local channel_remote = {} local channel_id = harbor_id local NORET = {} local function get_address(t, id) local v = assert(datacenter.get("multicast", id)) t[id] = v return v end local node_address = setmetatable({}, { __index = get_address }) -- new LOCAL channel , The low 8bit is the same with harbor_id function command.NEW() while channel[channel_id] do channel_id = mc.nextid(channel_id) end channel[channel_id] = {} channel_n[channel_id] = 0 local ret = channel_id channel_id = mc.nextid(channel_id) return ret end -- MUST call by the owner node of channel, delete a remote channel function command.DELR(source, c) channel[c] = nil channel_n[c] = nil return NORET end -- delete a channel, if the channel is remote, forward the command to the owner node -- otherwise, delete the channel, and call all the remote node, DELR function command.DEL(source, c) local node = c % 256 if node ~= harbor_id then skynet.send(node_address[node], "lua", "DEL", c) return NORET end local remote = channel_remote[c] channel[c] = nil channel_n[c] = nil channel_remote[c] = nil if remote then for node in pairs(remote) do skynet.send(node_address[node], "lua", "DELR", c) end end return NORET end -- forward multicast message to a node (channel id use the session field) local function remote_publish(node, channel, source, ...) skynet.redirect(node_address[node], source, "multicast", channel, ...) end -- publish a message, for local node, use the message pointer (call mc.bind to add the reference) -- for remote node, call remote_publish. (call mc.unpack and skynet.tostring to convert message pointer to string) local function publish(c , source, pack, size) local group = channel[c] if group == nil then -- dead channel, delete the pack. mc.bind returns the pointer in pack local pack = mc.bind(pack, 1) mc.close(pack) return end mc.bind(pack, channel_n[c]) local msg = skynet.tostring(pack, size) for k in pairs(group) do -- the msg is a pointer to the real message, publish pointer in local is ok. skynet.redirect(k, source, "multicast", c , msg) end local remote = channel_remote[c] if remote then -- remote publish should unpack the pack, because we should not publish the pointer out. local _, msg, sz = mc.unpack(pack, size) local msg = skynet.tostring(msg,sz) for node in pairs(remote) do remote_publish(node, c, source, msg) end end end skynet.register_protocol { name = "multicast", id = skynet.PTYPE_MULTICAST, unpack = function(msg, sz) return mc.packremote(msg, sz) end, dispatch = publish, } -- publish a message, if the caller is remote, forward the message to the owner node (by remote_publish) -- If the caller is local, call publish function command.PUB(source, c, pack, size) assert(skynet.harbor(source) == harbor_id) local node = c % 256 if node ~= harbor_id then -- remote publish remote_publish(node, c, source, mc.remote(pack)) else publish(c, source, pack,size) end end -- the node (source) subscribe a channel -- MUST call by channel owner node (assert source is not local and channel is create by self) -- If channel is not exist, return true -- Else set channel_remote[channel] true function command.SUBR(source, c) local node = skynet.harbor(source) if not channel[c] then -- channel none exist return true end assert(node ~= harbor_id and c % 256 == harbor_id) local group = channel_remote[c] if group == nil then group = {} channel_remote[c] = group end group[node] = true end -- the service (source) subscribe a channel -- If the channel is remote, node subscribe it by send a SUBR to the owner . function command.SUB(source, c) local node = c % 256 if node ~= harbor_id then -- remote group if channel[c] == nil then if skynet.call(node_address[node], "lua", "SUBR", c) then return end if channel[c] == nil then -- double check, because skynet.call whould yield, other SUB may occur. channel[c] = {} channel_n[c] = 0 end end end local group = channel[c] if group and not group[source] then channel_n[c] = channel_n[c] + 1 group[source] = true end end -- MUST call by a node, unsubscribe a channel function command.USUBR(source, c) local node = skynet.harbor(source) assert(node ~= harbor_id) local group = assert(channel_remote[c]) group[node] = nil return NORET end -- Unsubscribe a channel, if the subscriber is empty and the channel is remote, send USUBR to the channel owner function command.USUB(source, c) local group = assert(channel[c]) if group[source] then group[source] = nil channel_n[c] = channel_n[c] - 1 if channel_n[c] == 0 then local node = c % 256 if node ~= harbor_id then -- remote group channel[c] = nil channel_n[c] = nil skynet.send(node_address[node], "lua", "USUBR", c) end end end return NORET end skynet.start(function() skynet.dispatch("lua", function(_,source, cmd, ...) local f = assert(command[cmd]) local result = f(source, ...) if result ~= NORET then skynet.ret(skynet.pack(result)) end end) local self = skynet.self() local id = skynet.harbor(self) assert(datacenter.set("multicast", id, self) == nil) end)
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nn/SpatialBatchNormalization.lua
20
1353
--[[ This file implements Batch Normalization as described in the paper: "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift" by Sergey Ioffe, Christian Szegedy This implementation is useful for inputs coming from convolution layers. For non-convolutional layers, see BatchNormalization.lua The operation implemented is: y = ( x - mean(x) ) -------------------- * gamma + beta standard-deviation(x) where gamma and beta are learnable parameters. The learning of gamma and beta is optional. Usage: with learnable parameters: nn.SpatialBatchNormalization(N [,eps] [,momentum]) where N = dimensionality of input without learnable parameters: nn.SpatialBatchNormalization(N [,eps] [,momentum], false) eps is a small value added to the variance to avoid divide-by-zero. Defaults to 1e-5 In training time, this layer keeps a running estimate of it's computed mean and std. The running sum is kept with a default momentum of 0.1 (unless over-ridden) In test time, this running mean/std is used to normalize. ]]-- local BN, parent = torch.class('nn.SpatialBatchNormalization', 'nn.BatchNormalization') BN.__version = 2 -- expected dimension of input BN.nDim = 4
mit
ironbee/ironbee-qa
tests/debuglog.lua
1
3308
-- ========================================================================= -- ========================================================================= -- Licensed to Qualys, Inc. (QUALYS) under one or more -- contributor license agreements. See the NOTICE file distributed with -- this work for additional information regarding copyright ownership. -- QUALYS licenses this file to You 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. -- ========================================================================= -- ========================================================================= -- -- This is an example IronBee lua module using the new FFI interface. -- -- Author: Brian Rectanus <brectanus@qualys.com> -- ========================================================================= -- =============================================== -- Define local aliases of any globals to be used. -- =============================================== local base = _G local ironbee = require("ironbee-ffi") -- =============================================== -- Declare the rest of the file as a module and -- register the module table with ironbee. -- =============================================== module(...) _COPYRIGHT = "Copyright (C) 2010-2011 Qualys, Inc." _DESCRIPTION = "IronBee example DebugLog module" _VERSION = "0.1" -- =============================================== -- This is called when the module loads -- -- ib: IronBee engine handle -- =============================================== function onModuleLoad(ib) ironbee.ib_log_debug(ib, 0, "TestLogLevel 0 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 1, "TestLogLevel 1 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 2, "TestLogLevel 2 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 3, "TestLogLevel 3 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 4, "TestLogLevel 4 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 5, "TestLogLevel 5 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 6, "TestLogLevel 6 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 7, "TestLogLevel 7 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 8, "TestLogLevel 8 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 9, "TestLogLevel 9 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) ironbee.ib_log_debug(ib, 10, "TestLogLevel 10 %s.onModuleLoad ib=%p", _NAME, ib.cvalue()) return 0 end
apache-2.0
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nn/L1Penalty.lua
16
1128
local L1Penalty, parent = torch.class('nn.L1Penalty','nn.Module') --This module acts as an L1 latent state regularizer, adding the --[gradOutput] to the gradient of the L1 loss. The [input] is copied to --the [output]. function L1Penalty:__init(l1weight, sizeAverage, provideOutput) parent.__init(self) self.l1weight = l1weight self.sizeAverage = sizeAverage or false if provideOutput == nil then self.provideOutput = true else self.provideOutput = provideOutput end end function L1Penalty:updateOutput(input) local m = self.l1weight if self.sizeAverage == true then m = m/input:nElement() end local loss = m*input:norm(1) self.loss = loss self.output = input return self.output end function L1Penalty:updateGradInput(input, gradOutput) local m = self.l1weight if self.sizeAverage == true then m = m/input:nElement() end self.gradInput:resizeAs(input):copy(input):sign():mul(m) if self.provideOutput == true then self.gradInput:add(gradOutput) end return self.gradInput end
mit
linkdd/cream-browser
example/rc.lua
1
2697
-- Load Cream-Browser's API require ("cream") -- keybindings local state = { all = { cream.state.all }, noedit = { cream.state.normal, cream.state.embed, cream.state.caret } } -- exit Cream-Browser cream.keys.map (state.all, { }, "zz", function (w) cream.util.quit () end) -- go to normal mode cream.keys.map (state.all, { }, "Escape", function (w) cream.inputbox.text ("") cream.state.current (cream.state.normal) end) -- close tab cream.keys.map (state.all, { "Control" }, "w", function (w) w:close () end) -- focus to inputbox cream.keys.map (state.noedit, { }, "colon", function (w) cream.inputbox.text (":") cream.inputbox.focus () end) cream.keys.map (state.noedit, { }, "/", function (w) cream.inputbox.text ("/") cream.inputbox.focus () cream.state.current (cream.state.search) end) cream.keys.map (state.noedit, { "Shift" }, "?", function (w) cream.inputbox.text ("?") cream.inputbox.focus () cream.state.current (cream.state.search) end) -- Special commands cream.keys.map (state.noedit, { }, "o", function (w) cream.inputbox.text (":open ") cream.inputbox.focus () end) cream.keys.map (state.noedit, { "Shift" }, "O", function (w) cream.inputbox.text (":open " .. w:uri ()) cream.inputbox.focus () end) cream.keys.map (state.noedit, { }, "t", function (w) cream.inputbox.text (":tabopen ") cream.inputbox.focus () end) cream.keys.map (state.noedit, { "Shift" }, "T", function (w) cream.inputbox.text (":tabopen " .. w:uri ()) cream.inputbox.focus () end) -- Yank/Paste cream.keys.map (state.noedit, { }, "y", function (w) cream.clipboard.primary:set (w:uri ()) cream.inputbox.text ("Yanked " .. w:uri ()) end) cream.keys.map (state.noedit, { }, "p", function (w) uri = cream.clipboard.primary:get () if uri ~= "" then w:open (uri) end end) cream.keys.map (state.noedit, { "Shift" }, "P", function (w) uri = cream.clipboard.primary:get () if uri ~= "" then notebook = cream.tab.current () notebook:new (uri) end end)
mit
medialab-prado/Interactivos-15-Ego
minetest-ego/games/adventuretest/mods/handle_schematics/save_restore.lua
3
2617
-- reserve the namespace save_restore = {} -- TODO: if this gets more versatile, add sanity checks for filename -- TODO: apart from allowing filenames, schems/<filename> also needs to be allowed -- TODO: save and restore ought to be library functions and not implemented in each individual mod! save_restore.save_data = function( filename, data ) local path = minetest.get_worldpath()..'/'..filename; local file = io.open( path, 'w' ); if( file ) then file:write( minetest.serialize( data )); file:close(); else print("[save_restore] Error: Savefile '"..tostring( path ).."' could not be written."); end end save_restore.restore_data = function( filename ) local path = minetest.get_worldpath()..'/'..filename; local file = io.open( path, 'r' ); if( file ) then local data = file:read("*all"); file:close(); return minetest.deserialize( data ); else print("[save_restore] Error: Savefile '"..tostring( path ).."' not found."); return {}; -- return empty table end end save_restore.file_exists = function( filename ) local path = minetest.get_worldpath()..'/'..filename; local file = save_restore.file_access( path, 'r' ); if( file ) then file:close(); return true; end return; end save_restore.create_directory = function( filename ) local path = minetest.get_worldpath()..'/'..filename; if( not( save_restore.file_exists( filename ))) then if( minetest.mkdir ) then minetest.mkdir( minetest.get_worldpath().."/schems"); else os.execute("mkdir \""..minetest.get_worldpath().."/schems".. "\""); end end end -- we only need the function io.open in a version that can read schematic files from diffrent places, -- even if a secure environment is enforced; this does require an exception for the mod local ie_io_open = io.open; if( minetest.request_insecure_environment ) then local ie, req_ie = _G, minetest.request_insecure_environment if req_ie then ie = req_ie() end if ie then ie_io_open = ie.io.open; end end -- only a certain type of files can be read and written save_restore.file_access = function( path, params ) if( (params=='r' or params=='rb') and ( string.find( path, '.mts', -4 ) or string.find( path, '.schematic', -11 ) or string.find( path, '.we', -3 ) or string.find( path, '.wem', -4 ) )) then return ie_io_open( path, params ); elseif( (params=='w' or params=='wb') and ( string.find( path, '.mts', -4 ) or string.find( path, '.schematic', -11 ) or string.find( path, '.we', -3 ) or string.find( path, '.wem', -4 ) )) then return ie_io_open( path, params ); end end
mit
Ashkanovich/jitsu-king
plugins/all.lua
264
4202
do data = load_data(_config.moderation.data) 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) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_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 table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'chat stats! \n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end return text end local function show_group_settings(target) local data = load_data(_config.moderation.data) if data[tostring(target)] then if data[tostring(target)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local settings = data[tostring(target)]['settings'] local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX return text end local function get_description(target) local data = load_data(_config.moderation.data) local data_cat = 'description' if not data[tostring(target)][data_cat] then return 'No description available.' end local about = data[tostring(target)][data_cat] return about end local function get_rules(target) local data = load_data(_config.moderation.data) local data_cat = 'rules' if not data[tostring(target)][data_cat] then return 'No rules available.' end local rules = data[tostring(target)][data_cat] return rules end local function modlist(target) local data = load_data(_config.moderation.data) if not data[tostring(target)] then return 'Group is not added.' end if next(data[tostring(target)]['moderators']) == nil then return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators :\n' for k,v in pairs(data[tostring(target)]['moderators']) do message = message ..i..' - @'..v..' [' ..k.. '] \n' i = i + 1 end return message end local function get_link(target) local data = load_data(_config.moderation.data) local group_link = data[tostring(target)]['settings']['set_link'] if not group_link then return "No link" end return "Group link:\n"..group_link end local function all(target, receiver) local text = "All the things I know about this group \n \n" local settings = show_group_settings(target) text = text.."Group settings \n"..settings local rules = get_rules(target) text = text.."\n\nRules: \n"..rules local description = get_description(target) text = text.."\n\nAbout: \n"..description local modlist = modlist(target) text = text.."\n\n"..modlist local link = get_link(target) text = text.."\n\n"..link local stats = chat_stats(target) text = text.."\n\n"..stats local ban_list = ban_list(target) text = text.."\n\n"..ban_list local file = io.open("./groups/"..target.."all.txt", "w") file:write(text) file:flush() file:close() send_document(receiver,"./groups/"..target.."all.txt", ok_cb, false) return end function run(msg, matches) if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then local receiver = get_receiver(msg) local target = matches[2] return all(target, receiver) end if not is_owner(msg) then return end if matches[1] == "all" and not matches[2] and msg.to.id ~= our_id then local receiver = get_receiver(msg) if not is_owner(msg) then return end return all(msg.to.id, receiver) end return end return { patterns = { "^[!/](all)$", "^[!/](all) (%d+)$" }, run = run } end
gpl-2.0
rlcevg/Zero-K
units/cordoom.lua
1
8380
unitDef = { unitname = [[cordoom]], name = [[Doomsday Machine]], description = [[Medium Range Defense Fortress - Requires 50 Power (Main Gun)]], acceleration = 0, activateWhenBuilt = true, armoredMultiple = 0.25, brakeRate = 0, buildAngle = 4096, buildCostEnergy = 1600, buildCostMetal = 1600, builder = false, buildingGroundDecalDecaySpeed = 30, buildingGroundDecalSizeX = 5, buildingGroundDecalSizeY = 5, buildingGroundDecalType = [[cordoom_aoplane.dds]], buildPic = [[CORDOOM.png]], buildTime = 1600, canAttack = true, canstop = [[1]], category = [[SINK TURRET]], collisionVolumeOffsets = [[0 0 0]], collisionVolumeScales = [[45 100 45]], collisionVolumeTest = 1, collisionVolumeType = [[CylY]], corpse = [[DEAD]], customParams = { description_fr = [[Forteresse Arm?e]], description_de = [[Verteidigungsfestung mittlerer Reichweite - Benötigt ein angeschlossenes Stromnetz von 50 Energie, um feuern zu können.]], description_pl = [[Forteca obronna]], helptext = [[Armed with a heavy plasma cannon and a Heat Ray, the Doomsday Machine forms a focal defense point against enemy assault pushes. It can bunker down to survive attack by long-range artillery or air attacks to reduce incoming damage to a quarter, although it cannot fire its weapons while doing so.]], helptext_fr = [[Arm?e d'un canon plasma lourd de moyenne port?e et d'un rayon ? chaleur la Doomday Machine ou DDM comme on la surnomme, est capable de faire face ? tous type de menace. Nu?e, unit?s blind?es voire aerienne si assez proche, tout y passe! Son prix relativement ?lev? en limite cependant l'usage.]], helptext_de = [[Bewaffnet mit einer schweren Plasmakanone und einem Hitzestrahl nimmt die Doomsday Machine einen zentralen Punkt in der Verteidigung gegen feindliche Angriffsoffensiven ein. Die Maschine kann sich verbarrikadieren, um weitreichenden Artilleriebeschuss oder Luftangriffe zu ?erstehen, dabei kann sie aber nicht weiter feuern.]], helptext_pl = [[Na uzbrojenie tej wiezy sklada sie promien cieplny, ktory zadaje tym wiecej obrazen, im blizej znajduje sie cel, oraz ciezkie dzialo plazmowe, ktore zadaje wysokie obrazenia na duzym obszarze, ale ktore do strzalu wymaga, aby wieza byla podlaczona do sieci energetycznej o mocy co najmniej 50 energii. W trybie przetrwania glowne dzialo nie strzela, ale obrazenia otrzymywane przez wieze zmniejszaja sie czterokrotnie.]], keeptooltip = [[any string I want]], neededlink = 50, pylonrange = 50, extradrawrange = 430, aimposoffset = [[0 30 0]], midposoffset = [[0 0 0]], modelradius = [[20]], }, damageModifier = 0.25, explodeAs = [[ESTOR_BUILDING]], footprintX = 3, footprintZ = 3, iconType = [[staticassaultriot]], idleAutoHeal = 5, idleTime = 1800, levelGround = false, losEmitHeight = 70, mass = 636, maxDamage = 10000, maxSlope = 18, maxVelocity = 0, maxWaterDepth = 0, minCloakDistance = 150, noChaseCategory = [[FIXEDWING LAND SHIP SATELLITE SWIM GUNSHIP SUB HOVER]], objectName = [[DDM.s3o]], onoffable = true, script = [[cordoom.lua]], seismicSignature = 4, selfDestructAs = [[ESTOR_BUILDING]], sfxtypes = { explosiongenerators = { [[custom:LARGE_MUZZLE_FLASH_FX]], }, }, side = [[CORE]], sightDistance = 780, turnRate = 0, useBuildingGroundDecal = true, workerTime = 0, yardMap = [[ooo ooo ooo]], weapons = { { def = [[PLASMA]], badTargetCategory = [[FIXEDWING GUNSHIP]], onlyTargetCategory = [[FIXEDWING SWIM LAND SINK TURRET FLOAT SHIP HOVER GUNSHIP]], }, { def = [[HEATRAY]], badTargetCategory = [[FIXEDWING]], onlyTargetCategory = [[FIXEDWING LAND SINK TURRET SHIP SWIM FLOAT GUNSHIP HOVER]], }, }, weaponDefs = { HEATRAY = { name = [[Heat Ray]], accuracy = 512, areaOfEffect = 20, cegTag = [[HEATRAY_CEG]], coreThickness = 0.5, craterBoost = 0, craterMult = 0, damage = { default = 51.1, planes = 51.1, subs = 2.625, }, duration = 0.3, dynDamageExp = 1, dynDamageInverted = false, explosionGenerator = [[custom:HEATRAY_HIT]], fallOffRate = 0.9, fireStarter = 90, heightMod = 1, impactOnly = true, impulseBoost = 0, impulseFactor = 0.4, interceptedByShieldType = 1, lodDistance = 10000, proximityPriority = 6, projectiles = 2, range = 430, reloadtime = 0.1, rgbColor = [[1 0.1 0]], rgbColor2 = [[1 1 0.25]], soundStart = [[weapon/heatray_fire]], thickness = 3.95284707521047, tolerance = 10000, turret = true, weaponType = [[LaserCannon]], weaponVelocity = 500, }, PLASMA = { name = [[Heavy Plasma Cannon]], areaOfEffect = 192, avoidFeature = false, burnBlow = true, craterBoost = 0.7, craterMult = 1.2, damage = { default = 1201, subs = 60, }, edgeEffectiveness = 0.7, explosionGenerator = [[custom:FLASHSMALLBUILDING]], fireStarter = 99, impulseBoost = 0, impulseFactor = 0.4, interceptedByShieldType = 1, noSelfDamage = true, proximityPriority = 6, range = 650, reloadtime = 3, soundHit = [[weapon/cannon/cannon_hit4]], --soundHitVolume = 70, soundStart = [[weapon/cannon/heavy_cannon2]], sprayangle = 768, turret = true, weaponType = [[Cannon]], weaponVelocity = 750, }, }, featureDefs = { DEAD = { description = [[Wreckage - Doomsday Machine]], blocking = true, category = [[corpses]], damage = 10000, energy = 0, featureDead = [[HEAP]], footprintX = 3, footprintZ = 3, height = [[20]], hitdensity = [[100]], metal = 640, object = [[ddm_dead.s3o]], reclaimable = true, reclaimTime = 640, seqnamereclamate = [[TREE1RECLAMATE]], world = [[All Worlds]], }, HEAP = { description = [[Debris - Doomsday Machine]], blocking = false, category = [[heaps]], damage = 10000, energy = 0, footprintX = 3, footprintZ = 3, height = [[4]], hitdensity = [[100]], metal = 320, object = [[debris3x3c.s3o]], reclaimable = true, reclaimTime = 320, }, }, } return lowerkeys({ cordoom = unitDef })
gpl-2.0
ikstream/Minstrel-Blues
measurement/minstrel-measurement/parsers/wpa_supplicant.lua
2
4003
require ('parsers/parsers') local pprint = require ('pprint') WpaSupplicant = { ssid = nil , priority = nil , mode = nil , key_mgmt = nil , psk = nil , auth_alg = nil , proto = nil , group = nil , pairwise = nil , unknown = nil } function WpaSupplicant:new (o) local o = o or {} setmetatable(o, self) self.__index = self return o end function WpaSupplicant:create () local o = WpaSupplicant:new () o.unknown = {} return o end function WpaSupplicant:__tostring () local unknown = "" for name, value in pairs ( self.unknown ) do unknown = unknown .. name .. " = " .. value .. "\n" end return "WpaSupplicant ssid: " .. ( self.id or "unset" ) .. " priority: " .. ( self.priority or "unset" ) .. " mode: " .. ( self.mode or "unset" ) .. " key_mgmt: " .. ( self.key_mgmt or "unset" ) .. " psk: " .. ( self.psk or "unset" ) .. " auth_alg: " .. ( self.auth_alg or "unset" ) .. " proto: " .. ( self.proto or "unset" ) .. " group: " .. ( self.group or "unset" ) .. " pairwise: " .. ( self.pairwise or "unset" ) .. " unknown: " .. unknown end function parse_wpa_supplicant_conf ( conf ) local out = {} if ( conf == nil ) then return out end if ( string.len ( conf ) == 0 ) then return out end local rest = conf local pos = 0 local state = true local name local value while ( rest ~= "" ) do local c = shead ( rest ) if ( c == "#" ) then state, rest, pos = skip_line_comment ( rest, "#", pos ) elseif ( c == "\n" ) then rest = stail ( rest ) pos = cursor ( pos ) else name, rest, pos = parse_ide ( rest, { '_' }, pos ) rest, pos = skip_layout ( rest, pos ) state, rest, pos = parse_str ( rest, "=", pos ) rest, pos = skip_layout ( rest, pos ) state, rest, pos = parse_str ( rest, "{", pos ) if ( state == false ) then value, rest, pos = parse_until ( rest, "\n", pos ) else if ( name == "network" ) then local network state, rest, pos = parse_str ( rest, "\n", pos ) network, rest, pos = parse_wpa_supplicant ( rest, pos ) out [ #out + 1 ] = network end end end end return out end function parse_wpa_supplicant ( network, pos ) local out = WpaSupplicant:create () local rest = network local state = true while ( shead ( rest ) ~= "}" ) do rest, pos = skip_layout ( rest, pos ) name, rest, pos = parse_ide ( rest, { '_' }, pos ) rest, pos = skip_layout ( rest, pos ) state, rest, pos = parse_str ( rest, "=", pos ) rest, pos, pos = skip_layout ( rest, pos ) value, rest, pos = parse_until ( rest, "\n", pos ) state, rest, pos = parse_str ( rest, "\n", pos ) if ( name == "ssid" ) then out.ssid = value elseif ( name == "priority" ) then out.priority = value elseif ( name == "mode" ) then out.mode = value elseif ( name == "key_mgmt" ) then out.key_mgmt = value elseif ( name == "psk" ) then out.psk = value elseif ( name == "auth_alg" ) then out.auth_alg = value elseif ( name == "proto" ) then out.proto = value elseif ( name == "group" ) then out.group = value elseif ( name == "pairwise" ) then out.pairwise = value else out.unknown [ name ] = value end end rest = stail ( rest ) pos = cursor ( pos ) return out, rest, pos end
gpl-2.0
MOSAVI17/BosstG
plugins/inpm.lua
1114
3008
do local 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 local function chat_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of Groups:\n*Use /join (ID) to join*\n\n ' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairsByKeys(settings) do if m == 'set_name' then name = n end end message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n ' end local file = io.open("./groups/lists/listed_groups.txt", "w") file:write(message) file:flush() file:close() return message end local function run(msg, matches) if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then local data = load_data(_config.moderation.data) if matches[1] == 'join' and data[tostring(matches[2])] then if is_banned(msg.from.id, matches[2]) then return 'You are banned.' end if is_gbanned(msg.from.id) then return 'You are globally banned.' end if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then return 'Group is private.' end local chat_id = "chat#id"..matches[2] local user_id = "user#id"..msg.from.id chat_add_user(chat_id, user_id, ok_cb, false) local group_name = data[tostring(matches[2])]['settings']['set_name'] return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")" elseif matches[1] == 'join' and not data[tostring(matches[2])] then return "Chat not found." end if matches[1] == 'chats'then if is_admin(msg) and msg.to.type == 'chat' then return chat_list(msg) elseif msg.to.type ~= 'chat' then return chat_list(msg) end end if matches[1] == 'chatlist'then if is_admin(msg) and msg.to.type == 'chat' then send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) elseif msg.to.type ~= 'chat' then send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) end end end end return { patterns = { "^[/!](chats)$", "^[/!](chatlist)$", "^[/!](join) (.*)$", "^[/!](kickme) (.*)$", "^!!tgservice (chat_add_user)$" }, run = run, } end
gpl-2.0
rlcevg/Zero-K
LuaUI/Configs/decoration_handler_defs.lua
12
8036
-- only level 1 is needed, rest can be autogenerated local commtypeTable = { ["1"] = { -- armcom ["0"] = { -- level back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 0, -13}, alpha = 0.6, }, }, chest = { { piece = "torso", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 0, 6}, alpha = 0.6, }, }, overhead = { { piece = "head", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 20, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {10, 6.3, 0}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-10, 6.3, 0}, alpha = 0.8, }, }, } }, ["2"] = { -- corcom ["0"] = { back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 0, -13}, alpha = 0.6, }, }, chest = { { piece = "torso", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 0, 10}, alpha = 0.6, }, }, overhead = { { piece = "head", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 24, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {15, 13, 0}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-15, 13, 0}, alpha = 0.8, }, }, } }, ["3"] = { -- commrecon ["0"] = { back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 12, -20}, alpha = 0.6, }, }, chest = { { piece = "torso", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 8, 16}, alpha = 0.6, }, }, overhead = { { piece = "head", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 18, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {15, 18, -1}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-15, 18, -1}, alpha = 0.8, }, }, } }, ["4"] = { -- commsupport ["0"] = { back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 5, -10}, alpha = 0.6, }, }, chest = { { piece = "torso", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 4, 16}, alpha = 0.6, }, }, overhead = { { piece = "head", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 16, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {15, 14, -1}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-15, 14, -1}, alpha = 0.8, }, }, } }, ["5"] = { -- benzcom ["0"] = { -- level back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 8, -10}, alpha = 0.6, }, }, chest = { { piece = "torso", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 6, 10}, alpha = 0.6, }, }, overhead = { { piece = "hat", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 16, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {12, 20, 0}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-12, 20, 0}, alpha = 0.8, }, }, } }, ["6"] = { -- cremcom ["0"] = { -- level back = { { piece = "torso", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 14, -23}, alpha = 0.6, }, }, chest = { { piece = "snout", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 0, 2}, alpha = 0.6, }, }, overhead = { { piece = "hat", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 16, 0}, alpha = 0.8, }, }, shoulders = { { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {13, 16, -7}, alpha = 0.8, }, { piece = "torso", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-13, 16, -7}, alpha = 0.8, }, }, } }, -- new Strike Comm ["7"] = { -- cremcom ["0"] = { -- level back = { { piece = "Breast", height = 10, width = 10, rotation = 180, rotVector = {0,1,0}, offset = {0, 14, -23}, alpha = 0.6, }, }, chest = { { piece = "Breast", height = 10, width = 10, rotation = 0, rotVector = {0,0,0}, offset = {0, 0, 2}, alpha = 0.6, }, }, overhead = { { piece = "Breast", height = 10, width = 10, rotation = 90, rotVector = {1,0,0}, offset = {0, 0, 22}, alpha = 0.8, }, }, shoulders = { { piece = "Breast", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {13, 16, -7}, alpha = 0.8, }, { piece = "Breast", height = 5, width = 5, rotation = 90, rotVector = {1,0,0}, offset = {-13, 16, -7}, alpha = 0.8, }, }, } }, } local levelSizeMults = {1, 1.1, 1.2, 1.25, 1.3} for index, commData in pairs(commtypeTable) do for level = 1, 5 do local key = tostring(level) commData[key] = Spring.Utilities.CopyTable(commData["0"], true) for part, partData in pairs(commData[key]) do for j = 1, #partData do local specs = partData[j] local mult = levelSizeMults[level] specs.height = specs.height * mult specs.width = specs.width * mult for k = 1,3 do specs.offset[k] = specs.offset[k] * mult end end end end end local function CopyTableToNumber(inTable) local ret = {} for key, data in pairs(inTable) do ret[tonumber(key)] = Spring.Utilities.CopyTable(data, true) end return ret end -- special handling -- raise commrecon shoulder icons above pauldrons for commtype = 3, 5, 2 do for i = 3, 5 do local partData = commtypeTable[tostring(commtype)][tostring(i)].shoulders for j=1,2 do if commtype == 3 then partData[j].offset[2] = partData[j].offset[2] + (i == 5 and 8 or 6) else partData[j].offset[2] = partData[j].offset[2] + (i == 5 and 6 or 4) end end end end -- Make dynamic comm tables. commtypeTable[1] = CopyTableToNumber(commtypeTable["7"]) commtypeTable[2] = CopyTableToNumber(commtypeTable["3"]) commtypeTable[3] = CopyTableToNumber(commtypeTable["4"]) commtypeTable[4] = CopyTableToNumber(commtypeTable["5"]) return commtypeTable
gpl-2.0
rlcevg/Zero-K
LuaRules/Configs/MetalSpots/Altair_Crossing_v3.lua
38
1516
return { spots = { {x = 3864, z = 2136, metal = 2.2}, {x = 888, z = 4024, metal = 1}, {x = 3944, z = 184, metal = 1}, {x = 568, z = 1928, metal = 2.2}, {x = 1528, z = 1560, metal = 2.6}, {x = 3640, z = 2056, metal = 2.2}, {x = 568, z = 3144, metal = 2.2}, {x = 1912, z = 4040, metal = 2.6}, {x = 1592, z = 4024, metal = 1}, {x = 360, z = 1800, metal = 2.2}, {x = 3240, z = 3992, metal = 1}, {x = 120, z = 3992, metal = 1}, {x = 3720, z = 904, metal = 2.2}, {x = 552, z = 872, metal = 2.2}, {x = 2360, z = 4024, metal = 1}, {x = 1784, z = 184, metal = 1}, {x = 2392, z = 152, metal = 1}, {x = 3736, z = 3096, metal = 2.2}, {x = 360, z = 3016, metal = 2.2}, {x = 1992, z = 120, metal = 2.6}, {x = 88, z = 152, metal = 1}, {x = 2392, z = 2376, metal = 2.6}, {x = 360, z = 2024, metal = 2.2}, {x = 936, z = 280, metal = 1}, {x = 3960, z = 3992, metal = 1}, {x = 376, z = 968, metal = 2.2}, {x = 3096, z = 152, metal = 1}, {x = 3544, z = 3288, metal = 2.2}, {x = 3800, z = 1848, metal = 2.2}, {x = 3528, z = 776, metal = 2.2}, } }
gpl-2.0
Satoshi-t/Re-SBS
lua/ai/boss-ai.lua
1
3280
sgs.ai_skill_playerchosen.bossdidong = function(self, targets) self:sort(self.enemies) for _, enemy in ipairs(self.enemies) do if enemy:faceUp() then return enemy end end end sgs.ai_skill_playerchosen.bossluolei = function(self, targets) self:sort(self.enemies) for _, enemy in ipairs(self.enemies) do if self:canAttack(enemy, self.player, sgs.DamageStruct_Thunder) then return enemy end end end sgs.ai_skill_playerchosen.bossguihuo = function(self, targets) self:sort(self.enemies) for _, enemy in ipairs(self.enemies) do if self:canAttack(enemy, self.player, sgs.DamageStruct_Fire) and (enemy:hasArmorEffect("vine") or enemy:getMark("@gale") > 0) then return enemy end end for _, enemy in ipairs(self.enemies) do if self:canAttack(enemy, self.player, sgs.DamageStruct_Fire) then return enemy end end end sgs.ai_skill_playerchosen.bossxiaoshou = function(self, targets) self:sort(self.enemies) for _, enemy in ipairs(self.enemies) do if enemy:getHp() > self.player:getHp() and self:canAttack(enemy, self.player) then return enemy end end end sgs.ai_armor_value.bossmanjia = function(card, player, self) if not card then return sgs.ai_armor_value.vine(player, self, true) end end sgs.ai_skill_invoke.bosslianyu = function(self, data) local value, avail = 0, 0 for _, enemy in ipairs(self.enemies) do if not self:damageIsEffective(enemy, sgs.DamageStruct_Fire, self.player) then continue end avail = avail + 1 if self:canAttack(enemy, self.player, sgs.DamageStruct_Fire) then value = value + 1 if enemy:hasArmorEffect("vine") or enemy:getMark("@gale") > 0 then value = value + 1 end end end return avail > 0 and value / avail >= 2 / 3 end sgs.ai_skill_invoke.bosssuoming = function(self, data) local value = 0 for _, enemy in ipairs(self.enemies) do if sgs.isGoodTarget(enemy, self.enemies, self) then value = value + 1 end end return value / #self.enemies >= 2 / 3 end sgs.ai_skill_playerchosen.bossxixing = function(self, targets) self:sort(self.enemies) for _, enemy in ipairs(self.enemies) do if enemy:isChained() and self:canAttack(enemy, self.player, sgs.DamageStruct_Thunder) then return enemy end end end sgs.ai_skill_invoke.bossqiangzheng = function(self, data) local value = 0 for _, enemy in ipairs(self.enemies) do if enemy:getHandcardNum() == 1 and (enemy:hasSkill("kongcheng") or (enemy:hasSkill("zhiji") and enemy:getMark("zhiji") == 0)) then value = value + 1 end end return value / #self.enemies < 2 / 3 end sgs.ai_skill_invoke.bossqushou = function(self, data) local sa = sgs.Sanguosha:cloneCard("savage_assault") local dummy_use = { isDummy = true } self:useTrickCard(sa, dummy_use) return (dummy_use.card ~= nil) end sgs.ai_skill_invoke.bossmojian = function(self, data) local aa = sgs.Sanguosha:cloneCard("archery_attack") local dummy_use = { isDummy = true } self:useTrickCard(aa, dummy_use) return (dummy_use.card ~= nil) end sgs.ai_skill_invoke.bossdanshu = function(self, data) if not self.player:isWounded() then return false end local zj = self.room:findPlayerBySkillName("guidao") if self.player:getHp() / self.player:getMaxHp() >= 0.5 and zj and self:isEnemy(zj) and self:canRetrial(zj) then return false end return true end
gpl-3.0
rlcevg/Zero-K
LuaRules/Configs/MetalSpots/Grts_Messa_008.lua
17
1312
return { spots = { -- Four metal spots in center {x = 6162, z = 6750, metal = 3}, {x = 5546, z = 6128, metal = 3}, {x = 6138, z = 5562, metal = 3}, {x = 6747, z = 6152, metal = 3}, -- 12 starting spots (2x3 on each side) {x = 1093, z = 9286, metal = 3}, {x = 1174, z = 7125, metal = 3}, {x = 1208, z = 3882, metal = 3}, {x = 1801, z = 1770, metal = 3}, {x = 11211, z = 3015, metal = 3}, {x = 11127, z = 5179, metal = 3}, {x = 11097, z = 8424, metal = 3}, {x = 10505, z = 10535, metal = 3}, {x = 1110, z = 8144, metal = 3}, {x = 1488, z = 2740, metal = 3}, {x = 11178, z = 4078, metal = 3}, {x = 10853, z = 9452, metal = 3}, -- 8 "pairs" of metal spots -- they are close, but not right next to one another {x = 2734, z = 9944, metal = 3}, {x = 2871, z = 10981, metal = 3}, {x = 5140, z = 8906, metal = 3}, {x = 4199, z = 7650, metal = 3}, {x = 7151, z = 3406, metal = 3}, {x = 8069, z = 4661, metal = 3}, {x = 3010, z = 2775, metal = 3}, {x = 3718, z = 1396, metal = 3}, {x = 8607, z = 10905, metal = 3}, {x = 9275, z = 9512, metal = 3}, {x = 2911, z = 5460, metal = 3}, {x = 4391, z = 4782, metal = 3}, {x = 7771, z = 7617, metal = 3}, {x = 9411, z = 6824, metal = 3}, {x = 9522, z = 2360, metal = 3}, {x = 9419, z = 1328, metal = 3}, } }
gpl-2.0
jimmyharris/luaposix
examples/signal.lua
8
1447
local sig = require "posix.signal" local unistd = require "posix.unistd" local syswait = require "posix.sys.wait" local function go (fn, ...) local cpid = unistd.fork () if cpid == 0 then -- run function as child unistd._exit (fn (...) or 0) else return cpid end end local verbose = #arg > 0 local function sleepx (secs) while true do secs = unistd.sleep (secs) if verbose then print ("sleep", secs) end if secs == 0 then return end end end local nchild, nsig = 0, 0 sig.signal (sig.SIGCHLD, function() local pid, status, code = syswait.wait (-1, syswait.WNOHANG) while pid do if pid ~= 0 then if verbose then print ("wait", pid, status, code) end nchild = nchild + 1 end pid, status, code = syswait.wait (-1, syswait.WNOHANG) end end) local function handler (signo) if verbose then print ("handled", signo) end nsig = nsig + 1 end sig.signal (sig.SIGUSR1, handler) sig.signal (sig.SIGUSR2, handler) sig.signal (60, handler) local function killp (nsig) return sig.kill (unistd.getppid (), nsig) end c1 = go (function() unistd.sleep (1); killp (sig.SIGUSR1); killp (sig.SIGUSR2) end) c2 = go (function() unistd.sleep (2); killp (sig.SIGUSR2); end) c3 = go (function() unistd.sleep (2); killp (sig.SIGUSR1) end) sleepx(3) if verbose then print ("children", nchild, "signals", nsig) else assert (nchild == 3) assert (nsig == 4) print '+++ tests OK +++' end
mit
notcake/glib
lua/glib/userid.lua
1
1387
local singleplayerId = nil function GLib.GetEveryoneId () return "Everyone" end if SERVER then function GLib.GetLocalId () return "Server" end elseif CLIENT then function GLib.GetLocalId () if not LocalPlayer or not LocalPlayer ().SteamID then return "STEAM_0:0:0" end return LocalPlayer ():SteamID () end end function GLib.GetPlayerId (ply) if not ply then return nil end if not ply:IsValid () then return nil end if type (ply.SteamID) ~= "function" then return nil end local steamId = ply:SteamID () if SERVER and game.SinglePlayer () and ply == ents.GetByIndex (1) then steamId = singleplayerId end if steamId == "NULL" then steamId = "BOT" end return steamId end function GLib.GetServerId () return "Server" end function GLib.GetSystemId () return "System" end if game.SinglePlayer () then if SERVER then concommand.Add ("glib_singleplayerid", function (_, _, args) singleplayerId = args [1] end ) umsg.Start ("glib_request_singleplayerid") umsg.End () elseif CLIENT then local function sendSinglePlayerId () GLib.WaitForLocalPlayer ( function () RunConsoleCommand ("glib_singleplayerid", GLib.GetLocalId ()) end ) end usermessage.Hook ("glib_request_singleplayerid", sendSinglePlayerId) sendSinglePlayerId () end end
gpl-3.0
stanfordnlp/treelstm
relatedness/TreeLSTMSim.lua
10
7240
--[[ Semantic relatedness prediction using Tree-LSTMs. --]] local TreeLSTMSim = torch.class('treelstm.TreeLSTMSim') function TreeLSTMSim:__init(config) self.mem_dim = config.mem_dim or 150 self.learning_rate = config.learning_rate or 0.05 self.emb_learning_rate = config.emb_learning_rate or 0.0 self.batch_size = config.batch_size or 25 self.reg = config.reg or 1e-4 self.structure = config.structure or 'dependency' -- {dependency, constituency} self.sim_nhidden = config.sim_nhidden or 50 -- word embedding self.emb_dim = config.emb_vecs:size(2) self.emb = nn.LookupTable(config.emb_vecs:size(1), self.emb_dim) self.emb.weight:copy(config.emb_vecs) -- number of similarity rating classes self.num_classes = 5 -- optimizer configuration self.optim_state = { learningRate = self.learning_rate } -- KL divergence optimization objective self.criterion = nn.DistKLDivCriterion() -- initialize tree-lstm model local treelstm_config = { in_dim = self.emb_dim, mem_dim = self.mem_dim, gate_output = false, } if self.structure == 'dependency' then self.treelstm = treelstm.ChildSumTreeLSTM(treelstm_config) elseif self.structure == 'constituency' then self.treelstm = treelstm.BinaryTreeLSTM(treelstm_config) else error('invalid parse tree type: ' .. self.structure) end -- similarity model self.sim_module = self:new_sim_module() local modules = nn.Parallel() :add(self.treelstm) :add(self.sim_module) self.params, self.grad_params = modules:getParameters() end function TreeLSTMSim:new_sim_module() local vecs_to_input local lvec = nn.Identity()() local rvec = nn.Identity()() local mult_dist = nn.CMulTable(){lvec, rvec} local add_dist = nn.Abs()(nn.CSubTable(){lvec, rvec}) local vec_dist_feats = nn.JoinTable(1){mult_dist, add_dist} vecs_to_input = nn.gModule({lvec, rvec}, {vec_dist_feats}) -- define similarity model architecture local sim_module = nn.Sequential() :add(vecs_to_input) :add(nn.Linear(2 * self.mem_dim, self.sim_nhidden)) :add(nn.Sigmoid()) -- does better than tanh :add(nn.Linear(self.sim_nhidden, self.num_classes)) :add(nn.LogSoftMax()) return sim_module end function TreeLSTMSim:train(dataset) self.treelstm:training() local indices = torch.randperm(dataset.size) local zeros = torch.zeros(self.mem_dim) for i = 1, dataset.size, self.batch_size do xlua.progress(i, dataset.size) local batch_size = math.min(i + self.batch_size - 1, dataset.size) - i + 1 -- get target distributions for batch local targets = torch.zeros(batch_size, self.num_classes) for j = 1, batch_size do local sim = dataset.labels[indices[i + j - 1]] * (self.num_classes - 1) + 1 local ceil, floor = math.ceil(sim), math.floor(sim) if ceil == floor then targets[{j, floor}] = 1 else targets[{j, floor}] = ceil - sim targets[{j, ceil}] = sim - floor end end local feval = function(x) self.grad_params:zero() self.emb:zeroGradParameters() local loss = 0 for j = 1, batch_size do local idx = indices[i + j - 1] local ltree, rtree = dataset.ltrees[idx], dataset.rtrees[idx] local lsent, rsent = dataset.lsents[idx], dataset.rsents[idx] self.emb:forward(lsent) local linputs = torch.Tensor(self.emb.output:size()):copy(self.emb.output) local rinputs = self.emb:forward(rsent) -- get sentence representations local lrep = self.treelstm:forward(ltree, linputs)[2] local rrep = self.treelstm:forward(rtree, rinputs)[2] -- compute relatedness local output = self.sim_module:forward{lrep, rrep} -- compute loss and backpropagate local example_loss = self.criterion:forward(output, targets[j]) loss = loss + example_loss local sim_grad = self.criterion:backward(output, targets[j]) local rep_grad = self.sim_module:backward({lrep, rrep}, sim_grad) local linput_grads = self.treelstm:backward(dataset.ltrees[idx], linputs, {zeros, rep_grad[1]}) local rinput_grads = self.treelstm:backward(dataset.rtrees[idx], rinputs, {zeros, rep_grad[2]}) self.emb:backward(lsent, linput_grads) self.emb:backward(rsent, rinput_grads) end loss = loss / batch_size self.grad_params:div(batch_size) self.emb.gradWeight:div(batch_size) self.emb:updateParameters(self.emb_learning_rate) -- regularization loss = loss + 0.5 * self.reg * self.params:norm() ^ 2 self.grad_params:add(self.reg, self.params) return loss, self.grad_params end optim.adagrad(feval, self.params, self.optim_state) end xlua.progress(dataset.size, dataset.size) end -- Predict the similarity of a sentence pair. function TreeLSTMSim:predict(ltree, rtree, lsent, rsent) local linputs = self.emb:forward(lsent) local lrep = self.treelstm:forward(ltree, linputs)[2] local rinputs = self.emb:forward(rsent) local rrep = self.treelstm:forward(rtree, rinputs)[2] local output = self.sim_module:forward{lrep, rrep} self.treelstm:clean(ltree) self.treelstm:clean(rtree) return torch.range(1, 5):dot(output:exp()) end -- Produce similarity predictions for each sentence pair in the dataset. function TreeLSTMSim:predict_dataset(dataset) self.treelstm:evaluate() local predictions = torch.Tensor(dataset.size) for i = 1, dataset.size do xlua.progress(i, dataset.size) local ltree, rtree = dataset.ltrees[i], dataset.rtrees[i] local lsent, rsent = dataset.lsents[i], dataset.rsents[i] predictions[i] = self:predict(ltree, rtree, lsent, rsent) end return predictions end function TreeLSTMSim:print_config() local num_params = self.params:size(1) local num_sim_params = self:new_sim_module():getParameters():size(1) printf('%-25s = %d\n', 'num params', num_params) printf('%-25s = %d\n', 'num compositional params', num_params - num_sim_params) printf('%-25s = %d\n', 'word vector dim', self.emb_dim) printf('%-25s = %d\n', 'Tree-LSTM memory dim', self.mem_dim) printf('%-25s = %.2e\n', 'regularization strength', self.reg) printf('%-25s = %d\n', 'minibatch size', self.batch_size) printf('%-25s = %.2e\n', 'learning rate', self.learning_rate) printf('%-25s = %.2e\n', 'word vector learning rate', self.emb_learning_rate) printf('%-25s = %s\n', 'parse tree type', self.structure) printf('%-25s = %d\n', 'sim module hidden dim', self.sim_nhidden) end -- -- Serialization -- function TreeLSTMSim:save(path) local config = { batch_size = self.batch_size, emb_vecs = self.emb.weight:float(), learning_rate = self.learning_rate, emb_learning_rate = self.emb_learning_rate, mem_dim = self.mem_dim, sim_nhidden = self.sim_nhidden, reg = self.reg, structure = self.structure, } torch.save(path, { params = self.params, config = config, }) end function TreeLSTMSim.load(path) local state = torch.load(path) local model = treelstm.TreeLSTMSim.new(state.config) model.params:copy(state.params) return model end
gpl-2.0
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nn/MaskedSelect.lua
17
2507
local unpack = unpack or table.unpack local MaskedSelect, parent = torch.class('nn.MaskedSelect', 'nn.Module') --[[ Sets the provided mask value for the module. ]] function MaskedSelect:__init() parent.__init(self) self._maskIndices = torch.LongTensor() self._maskIndexBuffer = torch.LongTensor() self._maskIndexBufferCPU = torch.FloatTensor() self._gradBuffer = torch.Tensor() self._gradMask = torch.ByteTensor() end --[[ Performs maskedSelect operation. ]] function MaskedSelect:updateOutput(input) local input, mask = unpack(input) self.output:maskedSelect(input, mask) return self.output end --[[ Reverse maps unmasked gradOutput back to gradInput. ]] function MaskedSelect:updateGradInput(input, gradOutput) local input, mask = unpack(input) if input:type() == 'torch.CudaTensor' then self._maskIndexBufferCPU:range(1, mask:nElement()):resize(mask:size()) self._maskIndexBuffer:resize( self._maskIndexBufferCPU:size()):copy(self._maskIndexBufferCPU) else self._maskIndexBuffer:range(1, mask:nElement()):resize(mask:size()) end self._maskIndices:maskedSelect(self._maskIndexBuffer, mask) self._gradBuffer:resize(input:nElement()):zero() self._gradBuffer:scatter(1, self._maskIndices, gradOutput) self._gradBuffer:resize(input:size()) self.gradInput = {self._gradBuffer, self._gradMask:resize(mask:size()):fill(0)} return self.gradInput end function MaskedSelect:type(type, tensorCache) if not type then return self._type end self._gradBuffer = self._gradBuffer:type(type) self.gradInput = self.gradInput:type(type) self.output = self.output:type(type) -- These casts apply when switching between cuda/non-cuda types if type ~= 'torch.CudaTensor' then self._maskIndexBuffer = self._maskIndexBuffer:long() self._maskIndices = self._maskIndices:long() self._gradMask = self._gradMask:byte() elseif type == 'torch.CudaTensor' then self._maskIndexBuffer = self._maskIndexBuffer:cuda() self._maskIndices = self._maskIndices:cuda() self._gradMask = self._gradMask:cuda() end self._type = type return self end function MaskedSelect:clearState() return nn.utils.clear(self, {'output', 'gradInput', '_maskIndexBuffer', '_maskIndexBufferCPU', '_maskIndices', '_gradBuffer', '_gradMask'}) end
mit
Jeffyrao/nn
Reshape.lua
42
1801
local Reshape, parent = torch.class('nn.Reshape', 'nn.Module') function Reshape:__init(...) parent.__init(self) local arg = {...} self.size = torch.LongStorage() self.batchsize = torch.LongStorage() if torch.type(arg[#arg]) == 'boolean' then self.batchMode = arg[#arg] table.remove(arg, #arg) end local n = #arg if n == 1 and torch.typename(arg[1]) == 'torch.LongStorage' then self.size:resize(#arg[1]):copy(arg[1]) else self.size:resize(n) for i=1,n do self.size[i] = arg[i] end end self.nelement = 1 self.batchsize:resize(#self.size+1) for i=1,#self.size do self.nelement = self.nelement * self.size[i] self.batchsize[i+1] = self.size[i] end -- only used for non-contiguous input or gradOutput self._input = torch.Tensor() self._gradOutput = torch.Tensor() end function Reshape:updateOutput(input) if not input:isContiguous() then self._input:resizeAs(input) self._input:copy(input) input = self._input end if (self.batchMode == false) or ( (self.batchMode == nil) and (input:nElement() == self.nelement and input:size(1) ~= 1) ) then self.output:view(input, self.size) else self.batchsize[1] = input:size(1) self.output:view(input, self.batchsize) end return self.output end function Reshape:updateGradInput(input, gradOutput) if not gradOutput:isContiguous() then self._gradOutput:resizeAs(gradOutput) self._gradOutput:copy(gradOutput) gradOutput = self._gradOutput end self.gradInput:viewAs(gradOutput, input) return self.gradInput end function Reshape:__tostring__() return torch.type(self) .. '(' .. table.concat(self.size:totable(), 'x') .. ')' end
bsd-3-clause
Amadiro/obtuse-tanuki
libs/winapi/listboxclass.lua
2
2614
--oo/listbox: standard listbox control. --Written by Cosmin Apreutesei. Public Domain. setfenv(1, require'winapi') require'winapi.controlclass' require'winapi.itemlist' require'winapi.listbox' LBItemList = class(ItemList) function LBItemList:add(i,s) if not s then i,s = nil,i end if i then ListBox_InsertString(self.hwnd, i, s) else ListBox_AddString(self.hwnd, s) end end function LBItemList:remove(i) ListBox_DeleteString(self.hwnd, i) end local function setitem(hwnd, i, s) ListBox_InsertString(hwnd, i, s) ListBox_DeleteString(hwnd, i+1) end function LBItemList:set(i,s) --there's no ListBox_SetString so we have to improvize self.window:batch_update(setitem, self.hwnd, i, s) end function LBItemList:get(i) return ListBox_GetString(self.hwnd, i) end function LBItemList:get_count() return ListBox_GetCount(self.hwnd) end function LBItemList:select(i) ListBox_SetCurSel(self.hwnd, i) end function LBItemList:get_selected_index() return ListBox_GetCurSel(self.hwnd) end function LBItemList:get_selected() local si = self:get_selected_index() return si and self:get(si) end --for ownerdraw lists only function LBItemList:set_height(i, h) ListBox_SetItemHeight(self.hwnd, i, h) end function LBItemList:get_height(i) return ListBox_GetItemHeight(self.hwnd, i) end ListBox = subclass({ __style_bitmask = bitmask{ border = WS_BORDER, sort = LBS_SORT, select = { single = 0, multiple = LBS_MULTIPLESEL, extended = LBS_EXTENDEDSEL, }, tabstops = LBS_USETABSTOPS, free_height = LBS_NOINTEGRALHEIGHT, multicolumn = LBS_MULTICOLUMN, always_show_scrollbar = LBS_DISABLENOSCROLL, vscroll = WS_VSCROLL, hscroll = WS_HSCROLL, allow_select = negate(LBS_NOSEL), }, __style_ex_bitmask = bitmask{ client_edge = WS_EX_CLIENTEDGE, }, __defaults = { client_edge = true, always_show_scrollbar = true, free_height = true, --window properties w = 100, h = 100, }, __init_properties = {'sort'}, --LBS_SORT is not set initially. why? __wm_command_handler_names = index{ on_memory_error = LBN_ERRSPACE, on_select = LBN_SELCHANGE, on_double_click = LBN_DBLCLK, on_cancel = LBN_SELCANCEL, on_focus = LBN_SETFOCUS, on_blur = LBN_KILLFOCUS, }, }, Control) function ListBox:__before_create(info, args) ListBox.__index.__before_create(self, info, args) args.class = WC_LISTBOX args.style = bit.bor(args.style, LBS_NOTIFY, LBS_HASSTRINGS, LBS_WANTKEYBOARDINPUT) args.text = info.text end function ListBox:__init(info) ListBox.__index.__init(self, info) self.items = LBItemList(self) end function ListBox:LB_GETTEXT() --print'LB_GETTEXT' end
mit
tnarik/malmo
Malmo/test/LuaTests/test_argument_parser.lua
2
1918
-- -------------------------------------------------------------------------------------------------- -- Copyright (c) 2016 Microsoft Corporation -- -- 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. -- -------------------------------------------------------------------------------------------------- -- Tests basic functionality of ArgumentParser. require 'libMalmoLua' parser = ArgumentParser( 'test_argument_parser.lua' ) parser:addOptionalFloatArgument( 'run', 'how far to run', 728.23 ) parser:addOptionalIntArgument( 'remote', 'who has the remote', -1 ) parser:addOptionalFlag( 'verbose', 'print lots of debugging information' ) parser:addOptionalStringArgument( 'mission', 'the mission filename', '' ) args2 = { '--run', '3', '--remote' } -- debug if not pcall( function() parser:parse( args2 ) end ) then os.exit(0) -- this is what we expect to happen end os.exit(1)
mit
hnakamur/luv_fiber_example
wait.lua
6
1308
local coroutine = require('coroutine') local debug = require 'debug' local fiber = {} function fiber.new(block) return function (callback) local paused local co = coroutine.create(block) local function formatError(err) local stack = debug.traceback(co, tostring(err)) if type(err) == "table" then err.message = stack return err end return stack end local function check(success, ...) if not success then if callback then return callback(formatError(...)) else error(formatError(...)) end end if not paused then return callback and callback(nil, ...) end paused = false end local function wait(fn) if type(fn) ~= "function" then error("can only wait on functions") end local sync, ret fn(function (...) if sync == nil then sync = true ret = {...} return end check(coroutine.resume(co, ...)) end) if sync then return unpack(ret) end sync = false paused = true return coroutine.yield() end local function await(fn) local results = {wait(fn)} if results[1] then error(results[1]) end return unpack(results, 2) end check(coroutine.resume(co, wait, await)) end end return fiber
mit
Mehranhpr/spam
plugins/plugins.lua
325
6164
do -- Returns the key (index) in the config.enabled_plugins table local function plugin_enabled( name ) for k,v in pairs(_config.enabled_plugins) do if name == v then return k end end -- If not found return false end -- Returns true if file exists in plugins folder local function plugin_exists( name ) for k,v in pairs(plugins_names()) do if name..'.lua' == v then return true end end return false end local function list_all_plugins(only_enabled) local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '❌' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '✔' end nact = nact+1 end if not only_enabled or status == '✔' then -- get the name v = string.match (v, "(.*)%.lua") text = text..nsum..'. '..v..' '..status..'\n' end end local text = text..'\nThere are '..nsum..' plugins installed.\n'..nact..' plugins enabled and '..nsum-nact..' disabled' return text end local function list_plugins(only_enabled) local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '❌' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '✔' end nact = nact+1 end if not only_enabled or status == '✔' then -- get the name v = string.match (v, "(.*)%.lua") text = text..v..' '..status..'\n' end end local text = text..'\n'..nact..' plugins enabled from '..nsum..' plugins installed.' return text end local function reload_plugins( ) plugins = {} load_plugins() return list_plugins(true) end local function enable_plugin( plugin_name ) print('checking if '..plugin_name..' exists') -- Check if plugin is enabled if plugin_enabled(plugin_name) then return 'Plugin '..plugin_name..' is enabled' end -- Checks if plugin exists if plugin_exists(plugin_name) then -- Add to the config table table.insert(_config.enabled_plugins, plugin_name) print(plugin_name..' added to _config table') save_config() -- Reload the plugins return reload_plugins( ) else return 'Plugin '..plugin_name..' does not exists' end end local function disable_plugin( name, chat ) -- Check if plugins exists if not plugin_exists(name) then return 'Plugin '..name..' does not exists' end local k = plugin_enabled(name) -- Check if plugin is enabled if not k then return 'Plugin '..name..' not enabled' end -- Disable and reload table.remove(_config.enabled_plugins, k) save_config( ) return reload_plugins(true) end local function disable_plugin_on_chat(receiver, plugin) if not plugin_exists(plugin) then return "Plugin doesn't exists" end if not _config.disabled_plugin_on_chat then _config.disabled_plugin_on_chat = {} end if not _config.disabled_plugin_on_chat[receiver] then _config.disabled_plugin_on_chat[receiver] = {} end _config.disabled_plugin_on_chat[receiver][plugin] = true save_config() return 'Plugin '..plugin..' disabled on this chat' end local function reenable_plugin_on_chat(receiver, plugin) if not _config.disabled_plugin_on_chat then return 'There aren\'t any disabled plugins' end if not _config.disabled_plugin_on_chat[receiver] then return 'There aren\'t any disabled plugins for this chat' end if not _config.disabled_plugin_on_chat[receiver][plugin] then return 'This plugin is not disabled' end _config.disabled_plugin_on_chat[receiver][plugin] = false save_config() return 'Plugin '..plugin..' is enabled again' end local function run(msg, matches) -- Show the available plugins if matches[1] == '!plugins' and is_sudo(msg) then --after changed to moderator mode, set only sudo return list_all_plugins() end -- Re-enable a plugin for this chat if matches[1] == 'enable' and matches[3] == 'chat' then local receiver = get_receiver(msg) local plugin = matches[2] print("enable "..plugin..' on this chat') return reenable_plugin_on_chat(receiver, plugin) end -- Enable a plugin if matches[1] == 'enable' and is_sudo(msg) then --after changed to moderator mode, set only sudo local plugin_name = matches[2] print("enable: "..matches[2]) return enable_plugin(plugin_name) end -- Disable a plugin on a chat if matches[1] == 'disable' and matches[3] == 'chat' then local plugin = matches[2] local receiver = get_receiver(msg) print("disable "..plugin..' on this chat') return disable_plugin_on_chat(receiver, plugin) end -- Disable a plugin if matches[1] == 'disable' and is_sudo(msg) then --after changed to moderator mode, set only sudo if matches[2] == 'plugins' then return 'This plugin can\'t be disabled' end print("disable: "..matches[2]) return disable_plugin(matches[2]) end -- Reload all the plugins! if matches[1] == 'reload' and is_sudo(msg) then --after changed to moderator mode, set only sudo return reload_plugins(true) end end return { description = "Plugin to manage other plugins. Enable, disable or reload.", usage = { moderator = { "!plugins disable [plugin] chat : disable plugin only this chat.", "!plugins enable [plugin] chat : enable plugin only this chat.", }, sudo = { "!plugins : list all plugins.", "!plugins enable [plugin] : enable plugin.", "!plugins disable [plugin] : disable plugin.", "!plugins reload : reloads all plugins." }, }, patterns = { "^!plugins$", "^!plugins? (enable) ([%w_%.%-]+)$", "^!plugins? (disable) ([%w_%.%-]+)$", "^!plugins? (enable) ([%w_%.%-]+) (chat)", "^!plugins? (disable) ([%w_%.%-]+) (chat)", "^!plugins? (reload)$" }, run = run, moderated = true, -- set to moderator mode --privileged = true } end
gpl-2.0
EliHar/Pattern_recognition
torch1/exe/luajit-rocks/luajit-2.0/src/jit/dump.lua
4
19566
---------------------------------------------------------------------------- -- LuaJIT compiler dump module. -- -- Copyright (C) 2005-2015 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module can be used to debug the JIT compiler itself. It dumps the -- code representations and structures used in various compiler stages. -- -- Example usage: -- -- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" -- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R -- luajit -jdump=is myapp.lua | less -R -- luajit -jdump=-b myapp.lua -- luajit -jdump=+aH,myapp.html myapp.lua -- luajit -jdump=ixT,myapp.dump myapp.lua -- -- The first argument specifies the dump mode. The second argument gives -- the output file name. Default output is to stdout, unless the environment -- variable LUAJIT_DUMPFILE is set. The file is overwritten every time the -- module is started. -- -- Different features can be turned on or off with the dump mode. If the -- mode starts with a '+', the following features are added to the default -- set of features; a '-' removes them. Otherwise the features are replaced. -- -- The following dump features are available (* marks the default): -- -- * t Print a line for each started, ended or aborted trace (see also -jv). -- * b Dump the traced bytecode. -- * i Dump the IR (intermediate representation). -- r Augment the IR with register/stack slots. -- s Dump the snapshot map. -- * m Dump the generated machine code. -- x Print each taken trace exit. -- X Print each taken trace exit and the contents of all registers. -- a Print the IR of aborted traces, too. -- -- The output format can be set with the following characters: -- -- T Plain text output. -- A ANSI-colored text output -- H Colorized HTML + CSS output. -- -- The default output format is plain text. It's set to ANSI-colored text -- if the COLORTERM variable is set. Note: this is independent of any output -- redirection, which is actually considered a feature. -- -- You probably want to use less -R to enjoy viewing ANSI-colored text from -- a pipe or a file. Add this to your ~/.bashrc: export LESS="-R" -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr local bit = require("bit") local band, shl, shr = bit.band, bit.lshift, bit.rshift local sub, gsub, format = string.sub, string.gsub, string.format local byte, char, rep = string.byte, string.char, string.rep local type, tostring = type, tostring local stdout, stderr = io.stdout, io.stderr -- Load other modules on-demand. local bcline, disass -- Active flag, output file handle and dump mode. local active, out, dumpmode ------------------------------------------------------------------------------ local symtabmt = { __index = false } local symtab = {} local nexitsym = 0 -- Fill nested symbol table with per-trace exit stub addresses. local function fillsymtab_tr(tr, nexit) local t = {} symtabmt.__index = t if jit.arch == "mips" or jit.arch == "mipsel" then t[traceexitstub(tr, 0)] = "exit" return end for i=0,nexit-1 do local addr = traceexitstub(tr, i) t[addr] = tostring(i) end local addr = traceexitstub(tr, nexit) if addr then t[addr] = "stack_check" end end -- Fill symbol table with trace exit stub addresses. local function fillsymtab(tr, nexit) local t = symtab if nexitsym == 0 then local ircall = vmdef.ircall for i=0,#ircall do local addr = ircalladdr(i) if addr ~= 0 then t[addr] = ircall[i] end end end if nexitsym == 1000000 then -- Per-trace exit stubs. fillsymtab_tr(tr, nexit) elseif nexit > nexitsym then -- Shared exit stubs. for i=nexitsym,nexit-1 do local addr = traceexitstub(i) if addr == nil then -- Fall back to per-trace exit stubs. fillsymtab_tr(tr, nexit) setmetatable(symtab, symtabmt) nexit = 1000000 break end t[addr] = tostring(i) end nexitsym = nexit end return t end local function dumpwrite(s) out:write(s) end -- Disassemble machine code. local function dump_mcode(tr) local info = traceinfo(tr) if not info then return end local mcode, addr, loop = tracemc(tr) if not mcode then return end if not disass then disass = require("jit.dis_"..jit.arch) end out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") local ctx = disass.create(mcode, addr, dumpwrite) ctx.hexdump = 0 ctx.symtab = fillsymtab(tr, info.nexit) if loop ~= 0 then symtab[addr+loop] = "LOOP" ctx:disass(0, loop) out:write("->LOOP:\n") ctx:disass(loop, #mcode-loop) symtab[addr+loop] = nil else ctx:disass(0, #mcode) end end ------------------------------------------------------------------------------ local irtype_text = { [0] = "nil", "fal", "tru", "lud", "str", "p32", "thr", "pro", "fun", "p64", "cdt", "tab", "udt", "flt", "num", "i8 ", "u8 ", "i16", "u16", "int", "u32", "i64", "u64", "sfp", } local colortype_ansi = { [0] = "%s", "%s", "%s", "\027[36m%s\027[m", "\027[32m%s\027[m", "%s", "\027[1m%s\027[m", "%s", "\027[1m%s\027[m", "%s", "\027[33m%s\027[m", "\027[31m%s\027[m", "\027[36m%s\027[m", "\027[34m%s\027[m", "\027[34m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", } local function colorize_text(s, t) return s end local function colorize_ansi(s, t) return format(colortype_ansi[t], s) end local irtype_ansi = setmetatable({}, { __index = function(tab, t) local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) local html_escape = { ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;", } local function colorize_html(s, t) s = gsub(s, "[<>&]", html_escape) return format('<span class="irt_%s">%s</span>', irtype_text[t], s) end local irtype_html = setmetatable({}, { __index = function(tab, t) local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) local header_html = [[ <style type="text/css"> background { background: #ffffff; color: #000000; } pre.ljdump { font-size: 10pt; background: #f0f4ff; color: #000000; border: 1px solid #bfcfff; padding: 0.5em; margin-left: 2em; margin-right: 2em; } span.irt_str { color: #00a000; } span.irt_thr, span.irt_fun { color: #404040; font-weight: bold; } span.irt_tab { color: #c00000; } span.irt_udt, span.irt_lud { color: #00c0c0; } span.irt_num { color: #4040c0; } span.irt_int, span.irt_i8, span.irt_u8, span.irt_i16, span.irt_u16 { color: #b040b0; } </style> ]] local colorize, irtype -- Lookup tables to convert some literals into names. local litname = { ["SLOAD "] = setmetatable({}, { __index = function(t, mode) local s = "" if band(mode, 1) ~= 0 then s = s.."P" end if band(mode, 2) ~= 0 then s = s.."F" end if band(mode, 4) ~= 0 then s = s.."T" end if band(mode, 8) ~= 0 then s = s.."C" end if band(mode, 16) ~= 0 then s = s.."R" end if band(mode, 32) ~= 0 then s = s.."I" end t[mode] = s return s end}), ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, ["CONV "] = setmetatable({}, { __index = function(t, mode) local s = irtype[band(mode, 31)] s = irtype[band(shr(mode, 5), 31)].."."..s if band(mode, 0x400) ~= 0 then s = s.." trunc" elseif band(mode, 0x800) ~= 0 then s = s.." sext" end local c = shr(mode, 14) if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end t[mode] = s return s end}), ["FLOAD "] = vmdef.irfield, ["FREF "] = vmdef.irfield, ["FPMATH"] = vmdef.irfpm, } local function ctlsub(c) if c == "\n" then return "\\n" elseif c == "\r" then return "\\r" elseif c == "\t" then return "\\t" else return format("\\%03d", byte(c)) end end 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 local function formatk(tr, idx) local k, t, slot = tracek(tr, idx) local tn = type(k) local s if tn == "number" then if k == 2^52+2^51 then s = "bias" else s = format("%+.14g", k) end elseif tn == "string" then s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) elseif tn == "function" then s = fmtfunc(k) elseif tn == "table" then s = format("{%p}", k) elseif tn == "userdata" then if t == 12 then s = format("userdata:%p", k) else s = format("[%p]", k) if s == "[0x00000000]" then s = "NULL" end end elseif t == 21 then -- int64_t s = sub(tostring(k), 1, -3) if sub(s, 1, 1) ~= "-" then s = "+"..s end else s = tostring(k) -- For primitives. end s = colorize(format("%-4s", s), t) if slot then s = format("%s @%d", s, slot) end return s end local function printsnap(tr, snap) local n = 2 for s=0,snap[1]-1 do local sn = snap[n] if shr(sn, 24) == s then n = n + 1 local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS if ref < 0 then out:write(formatk(tr, ref)) elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) else local m, ot, op1, op2 = traceir(tr, ref) out:write(colorize(format("%04d", ref), band(ot, 31))) end out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME else out:write("---- ") end end out:write("]\n") end -- Dump snapshots (not interleaved with IR). local function dump_snap(tr) out:write("---- TRACE ", tr, " snapshots\n") for i=0,1000000000 do local snap = tracesnap(tr, i) if not snap then break end out:write(format("#%-3d %04d [ ", i, snap[0])) printsnap(tr, snap) end end -- Return a register name or stack slot for a rid/sp location. local function ridsp_name(ridsp, ins) if not disass then disass = require("jit.dis_"..jit.arch) end local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) if rid == 253 or rid == 254 then return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) end if ridsp > 255 then return format("[%x]", slot*4) end if rid < 128 then return disass.regname(rid) end return "" end -- Dump CALL* function ref and return optional ctype. local function dumpcallfunc(tr, ins) local ctype if ins > 0 then local m, ot, op1, op2 = traceir(tr, ins) if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). ins = op1 ctype = formatk(tr, op2) end end if ins < 0 then out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) else out:write(format("%04d (", ins)) end return ctype end -- Recursively gather CALL* args and dump them. local function dumpcallargs(tr, ins) if ins < 0 then out:write(formatk(tr, ins)) else local m, ot, op1, op2 = traceir(tr, ins) local oidx = 6*shr(ot, 8) local op = sub(vmdef.irnames, oidx+1, oidx+6) if op == "CARG " then dumpcallargs(tr, op1) if op2 < 0 then out:write(" ", formatk(tr, op2)) else out:write(" ", format("%04d", op2)) end else out:write(format("%04d", ins)) end end end -- Dump IR and interleaved snapshots. local function dump_ir(tr, dumpsnap, dumpreg) local info = traceinfo(tr) if not info then return end local nins = info.nins out:write("---- TRACE ", tr, " IR\n") local irnames = vmdef.irnames local snapref = 65536 local snap, snapno if dumpsnap then snap = tracesnap(tr, 0) snapref = snap[0] snapno = 0 end for ins=1,nins do if ins >= snapref then if dumpreg then out:write(format(".... SNAP #%-3d [ ", snapno)) else out:write(format(".... SNAP #%-3d [ ", snapno)) end printsnap(tr, snap) snapno = snapno + 1 snap = tracesnap(tr, snapno) snapref = snap and snap[0] or 65536 end local m, ot, op1, op2, ridsp = traceir(tr, ins) local oidx, t = 6*shr(ot, 8), band(ot, 31) local op = sub(irnames, oidx+1, oidx+6) if op == "LOOP " then if dumpreg then out:write(format("%04d ------------ LOOP ------------\n", ins)) else out:write(format("%04d ------ LOOP ------------\n", ins)) end elseif op ~= "NOP " and op ~= "CARG " and (dumpreg or op ~= "RENAME") then local rid = band(ridsp, 255) if dumpreg then out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) else out:write(format("%04d ", ins)) end out:write(format("%s%s %s %s ", (rid == 254 or rid == 253) and "}" or (band(ot, 128) == 0 and " " or ">"), band(ot, 64) == 0 and " " or "+", irtype[t], op)) local m1, m2 = band(m, 3), band(m, 3*4) if sub(op, 1, 4) == "CALL" then local ctype if m2 == 1*4 then -- op2 == IRMlit out:write(format("%-10s (", vmdef.ircall[op2])) else ctype = dumpcallfunc(tr, op2) end if op1 ~= -1 then dumpcallargs(tr, op1) end out:write(")") if ctype then out:write(" ctype ", ctype) end elseif op == "CNEW " and op2 == -1 then out:write(formatk(tr, op1)) elseif m1 ~= 3 then -- op1 != IRMnone if op1 < 0 then out:write(formatk(tr, op1)) else out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) end if m2 ~= 3*4 then -- op2 != IRMnone if m2 == 1*4 then -- op2 == IRMlit local litn = litname[op] if litn and litn[op2] then out:write(" ", litn[op2]) elseif op == "UREFO " or op == "UREFC " then out:write(format(" #%-3d", shr(op2, 8))) else out:write(format(" #%-3d", op2)) end elseif op2 < 0 then out:write(" ", formatk(tr, op2)) else out:write(format(" %04d", op2)) end end end out:write("\n") end end if snap then if dumpreg then out:write(format(".... SNAP #%-3d [ ", snapno)) else out:write(format(".... SNAP #%-3d [ ", snapno)) end printsnap(tr, snap) end end ------------------------------------------------------------------------------ local recprefix = "" local recdepth = 0 -- 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 == "stop" or (what == "abort" and dumpmode.a) then if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop") elseif dumpmode.s then dump_snap(tr) end if dumpmode.m then dump_mcode(tr) end end if what == "start" then if dumpmode.H then out:write('<pre class="ljdump">\n') end out:write("---- TRACE ", tr, " ", what) if otr then out:write(" ", otr, "/", oex) end out:write(" ", fmtfunc(func, pc), "\n") elseif what == "stop" or what == "abort" then out:write("---- TRACE ", tr, " ", what) if what == "abort" then out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n") else local info = traceinfo(tr) local link, ltype = info.link, info.linktype if link == tr or link == 0 then out:write(" -> ", ltype, "\n") elseif ltype == "root" then out:write(" -> ", link, "\n") else out:write(" -> ", link, " ", ltype, "\n") end end if dumpmode.H then out:write("</pre>\n\n") else out:write("\n") end else if what == "flush" then symtab, nexitsym = {}, 0 end out:write("---- TRACE ", what, "\n\n") end out:flush() end -- Dump recorded bytecode. local function dump_record(tr, func, pc, depth, callee) if depth ~= recdepth then recdepth = depth recprefix = rep(" .", depth) end local line if pc >= 0 then line = bcline(func, pc, recprefix) if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end else line = "0000 "..recprefix.." FUNCC \n" callee = func end if pc <= 0 then out:write(sub(line, 1, -2), " ; ", fmtfunc(func), "\n") else out:write(line) end if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. end end ------------------------------------------------------------------------------ -- Dump taken trace exits. local function dump_texit(tr, ex, ngpr, nfpr, ...) out:write("---- TRACE ", tr, " exit ", ex, "\n") if dumpmode.X then local regs = {...} if jit.arch == "x64" then for i=1,ngpr do out:write(format(" %016x", regs[i])) if i % 4 == 0 then out:write("\n") end end else for i=1,ngpr do out:write(format(" %08x", regs[i])) if i % 8 == 0 then out:write("\n") end end end if jit.arch == "mips" or jit.arch == "mipsel" then for i=1,nfpr,2 do out:write(format(" %+17.14g", regs[ngpr+i])) if i % 8 == 7 then out:write("\n") end end else for i=1,nfpr do out:write(format(" %+17.14g", regs[ngpr+i])) if i % 4 == 0 then out:write("\n") end end end end end ------------------------------------------------------------------------------ -- Detach dump handlers. local function dumpoff() if active then active = false jit.attach(dump_texit) jit.attach(dump_record) 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(opt, outfile) if active then dumpoff() end local colormode = os.getenv("COLORTERM") and "A" or "T" if opt then opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) end local m = { t=true, b=true, i=true, m=true, } if opt and opt ~= "" then local o = sub(opt, 1, 1) if o ~= "+" and o ~= "-" then m = {} end for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end end dumpmode = m if m.t or m.b or m.i or m.s or m.m then jit.attach(dump_trace, "trace") end if m.b then jit.attach(dump_record, "record") if not bcline then bcline = require("jit.bc").line end end if m.x or m.X then jit.attach(dump_texit, "texit") end if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stdout end m[colormode] = true if colormode == "A" then colorize = colorize_ansi irtype = irtype_ansi elseif colormode == "H" then colorize = colorize_html irtype = irtype_html out:write(header_html) else colorize = colorize_text irtype = irtype_text end active = true end -- Public module functions. module(...) on = dumpon off = dumpoff start = dumpon -- For -j command line option.
mit
DrFR0ST/Human-Apocalypse
conf.lua
1
2616
function love.conf(t) t.identity = nil -- The name of the save directory (string) --t.version = "0.1" -- The LÖVE version this game was made for (string) t.console = false -- Attach a console (boolean, Windows only) t.window.title = "Human-Apocalypse" -- The window title (string) t.window.author = "Mike '#DRFR0ST' Eling" t.window.icon = nil -- Filepath to an image to use as the window's icon (string) t.window.width = 1024 -- The window width (number) t.window.height = 768 -- The window height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.fullscreen = false -- Enable fullscreen (boolean) t.window.vsync = true -- Enable vertical sync (boolean) t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean). Added in 0.9.1 t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean). Added in 0.9.1 t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) t.modules.graphics = true -- Enable the graphics module (boolean) t.modules.image = true -- Enable the image module (boolean) t.modules.joystick = true -- Enable the joystick module (boolean) t.modules.keyboard = true -- Enable the keyboard module (boolean) t.modules.math = true -- Enable the math module (boolean) t.modules.mouse = true -- Enable the mouse module (boolean) t.modules.physics = true -- Enable the physics module (boolean) t.modules.sound = true -- Enable the sound module (boolean) t.modules.system = true -- Enable the system module (boolean) t.modules.timer = true -- Enable the timer module (boolean) t.modules.window = true -- Enable the window module (boolean) end
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/nn/MM.lua
17
2812
--[[ Module to perform matrix multiplication on two minibatch inputs, producing a minibatch. ]] local MM, parent = torch.class('nn.MM', 'nn.Module') --[[ The constructor takes two optional arguments, specifying whether or not transpose any of the input matrices before perfoming the multiplication. ]] function MM:__init(transA, transB) parent.__init(self) self.transA = transA or false self.transB = transB or false self.gradInput = {torch.Tensor(), torch.Tensor()} end function MM:updateOutput(input) assert(#input == 2, 'input must be a pair of minibatch matrices') local a, b = table.unpack(input) assert(a:nDimension() == 2 or a:nDimension() == 3, 'input tensors must be 2D or 3D') if a:nDimension() == 2 then assert(b:nDimension() == 2, 'second input tensor must be 2D') if self.transA then a = a:t() end if self.transB then b = b:t() end assert(a:size(2) == b:size(1), 'matrix sizes do not match') self.output:resize(a:size(1), b:size(2)) self.output:mm(a, b) else assert(b:nDimension() == 3, 'second input tensor must be 3D') assert(a:size(1) == b:size(1), 'inputs must contain the same number of minibatches') if self.transA then a = a:transpose(2, 3) end if self.transB then b = b:transpose(2, 3) end assert(a:size(3) == b:size(2), 'matrix sizes do not match') self.output:resize(a:size(1), a:size(2), b:size(3)) self.output:bmm(a, b) end return self.output end function MM:updateGradInput(input, gradOutput) self.gradInput[1] = self.gradInput[1] or input[1].new() self.gradInput[2] = self.gradInput[2] or input[2].new() assert(#input == 2, 'input must be a pair of tensors') local a, b = table.unpack(input) self.gradInput[1]:resizeAs(a) self.gradInput[2]:resizeAs(b) assert(gradOutput:nDimension() == 2 or gradOutput:nDimension() == 3, 'arguments must be a 2D or 3D Tensor') local h_dim, w_dim, f if gradOutput:nDimension() == 2 then assert(a:nDimension() == 2, 'first input tensor must be 2D') assert(b:nDimension() == 2, 'second input tensor must be 2D') h_dim, w_dim = 1, 2 f = "mm" else assert(a:nDimension() == 3, 'first input tensor must be 3D') assert(b:nDimension() == 3, 'second input tensor must be 3D') h_dim, w_dim = 2, 3 f = "bmm" end if self.transA == self.transB then a = a:transpose(h_dim, w_dim) b = b:transpose(h_dim, w_dim) end if self.transA then self.gradInput[1][f](self.gradInput[1], b, gradOutput:transpose(h_dim, w_dim)) else self.gradInput[1][f](self.gradInput[1], gradOutput, b) end if self.transB then self.gradInput[2][f](self.gradInput[2], gradOutput:transpose(h_dim, w_dim), a) else self.gradInput[2][f](self.gradInput[2], a, gradOutput) end return self.gradInput end
mit
EliHar/Pattern_recognition
torch1/install/share/lua/5.1/tds/vec.lua
4
6372
local ffi = require 'ffi' local tds = require 'tds.env' local elem = require 'tds.elem' local C = tds.C -- vec-independent temporary buffers local val__ = C.tds_elem_new() ffi.gc(val__, C.tds_elem_free) local vec = {} local NULL = not jit and ffi.C.NULL or nil local mt = {} function mt:insert(...) local lkey, lval if select('#', ...) == 1 then lkey, lval = #self+1, select(1, ...) elseif select('#', ...) == 2 then lkey, lval = select(1, ...), select(2, ...) else error('[key] value expected') end assert(self) assert(type(lkey) == 'number' and lkey > 0, 'positive number expected as key') if lval or type(lval) == 'boolean' then elem.set(val__, lval) else C.tds_elem_set_nil(val__) end if C.tds_vec_insert(self, lkey-1, val__) == 1 then error('out of memory') end end function mt:remove(lkey) lkey = lkey or #self assert(self) assert(type(lkey) == 'number' and lkey > 0, 'positive number expected as key') C.tds_vec_remove(self, lkey-1) end function mt:resize(size) assert(type(size) == 'number' and size >= 0, 'size must be a positive number') C.tds_vec_resize(self, size) end if pcall(require, 'torch') then function mt:concatstorage(sep, i, j) i = i or 1 j = j or #self local sepsize = 0 if sep then sep = torch.CharStorage():string(sep) sepsize = sep:size() end local buffer = torch.CharStorage() local size = 0 for k=i,j do local str = tostring(self[k]) assert(str, 'vector elements must return a non-nil tostring()') str = torch.CharStorage():string(str) local strsize = str:size() if size+strsize+sepsize > buffer:size() then buffer:resize(math.max(buffer:size()*1.5, size+strsize+sepsize)) end if sep and size > 0 then local view = torch.CharStorage(buffer, size+1, sepsize) view:copy(sep) size = size + sepsize end local view = torch.CharStorage(buffer, size+1, strsize) view:copy(str) size = size + strsize end buffer:resize(size) return buffer end function mt:concat(sep, i, j) return self:concatstorage(sep, i, j):string() end end function mt:sort(compare) if type(compare) == 'function' then local function compare__(cval1, cval2) local lval1, lval2 if C.tds_elem_isnil(cval1) == 0 then lval1 = elem.get(cval1) end if C.tds_elem_isnil(cval2) == 0 then lval2 = elem.get(cval2) end return compare(lval1, lval2) and -1 or 1 end local cb_compare__ = ffi.cast('int (*)(tds_elem*, tds_elem*)', compare__) C.tds_vec_sort(self, cb_compare__) cb_compare__:free() else -- you must know what you are doing assert(compare ~= nil, 'compare function must be a lua or C function') C.tds_vec_sort(self, compare) end end local function isvec(tbl) for k, v in pairs(tbl) do if type(k) ~= 'number' then return false end end return true end local function fill(self, tbl) assert(isvec(tbl), 'lua table with number keys expected') for key, val in pairs(tbl) do if type(val) == 'table' then if isvec(val) then self[key] = tds.Vec(val) else self[key] = tds.Hash(val) end else self[key] = val end end end function vec:__new(...) -- beware of the : local self = C.tds_vec_new() if self == NULL then error('unable to allocate vec') end self = ffi.cast('tds_vec&', self) ffi.gc(self, C.tds_vec_free) if select('#', ...) == 1 and type(select(1, ...)) == 'table' then fill(self, select(1, ...)) elseif select('#', ...) > 0 then fill(self, {...}) end return self end function vec:__newindex(lkey, lval) assert(self) assert(type(lkey) == 'number' and lkey > 0, 'positive number expected as key') if lval or type(lval) == 'boolean' then elem.set(val__, lval) else C.tds_elem_set_nil(val__) end if C.tds_vec_set(self, lkey-1, val__) == 1 then error('out of memory') end end function vec:__index(lkey) local lval assert(self) if type(lkey) == 'number' then assert(lkey > 0, 'positive number expected as key') C.tds_vec_get(self, lkey-1, val__) if C.tds_elem_isnil(val__) == 0 then lval = elem.get(val__) end else local method = rawget(mt, lkey) if method then return method else error('invalid key (number) or method name') end end return lval end function vec:__len() assert(self) return tonumber(C.tds_vec_size(self)) end function vec:__ipairs() assert(self) local k = 0 return function() k = k + 1 if k <= C.tds_vec_size(self) then return k, self[k] end end end vec.__pairs = vec.__ipairs ffi.metatype('tds_vec', vec) if pcall(require, 'torch') and torch.metatype then function vec:__write(f) f:writeLong(#self) for k,v in ipairs(self) do f:writeObject(v) end end function vec:__read(f) local n = f:readLong() for k=1,n do local v = f:readObject() self[k] = v end end vec.__factory = vec.__new vec.__version = 0 torch.metatype('tds.Vec', vec, 'tds_vec&') end function vec:__tostring() local str = {} table.insert(str, string.format('tds.Vec[%d]{', #self)) for k,v in ipairs(self) do local kstr = string.format("%5d : ", tostring(k)) local vstr = tostring(v) or type(v) local sp = string.rep(' ', #kstr) local i = 0 vstr = vstr:gsub( '([^\n]+)', function(line) i = i + 1 if i == 1 then return kstr .. line else return sp .. line end end ) table.insert(str, vstr) if k == 20 then table.insert(str, '...') break end end table.insert(str, '}') return table.concat(str, '\n') end -- table constructor local vec_ctr = {} setmetatable( vec_ctr, { __index = vec, __newindex = vec, __call = vec.__new } ) tds.vec = vec_ctr tds.Vec = vec_ctr return vec_ctr
mit
AlexMili/torch-dataframe
specs/dataframe/missing_data_spec.lua
1
1990
require 'lfs' -- Ensure the test is launched within the specs/ folder assert(string.match(lfs.currentdir(), "specs")~=nil, "You must run this test in specs folder") local initial_dir = lfs.currentdir() -- Go to specs folder while (not string.match(lfs.currentdir(), "/specs$")) do lfs.chdir("..") end local specs_dir = lfs.currentdir() lfs.chdir("..")-- one more directory and it is lib root -- Include Dataframe lib dofile("init.lua") -- Go back into initial dir lfs.chdir(initial_dir) describe("Dataframe class", function() it("Counts missing values", function() local a = Dataframe(specs_dir.."/data/full.csv") assert.are.same(a:count_na{as_dataframe = false}, {["Col A"]= 0, ["Col B"]= 0, ["Col C"]=1, ["Col D"]=1}) end) it("Fills missing value(s) for a given column(s)",function() local a = Dataframe(specs_dir.."/data/advanced_short.csv") assert.has.error(function() a:fill_na("Random column") end) a:fill_na("Col A", 1) assert.are.same(a:count_na{as_dataframe = false}, {["Col A"]= 0, ["Col B"]= 0, ["Col C"]=1}) a:fill_na("Col C", 1) assert.are.same(a:count_na{as_dataframe = false}, {["Col A"]= 0, ["Col B"]= 0, ["Col C"]=0}) assert.are.same(a:get_column("Col C"), {8, 1, 9}) end) it("Fills all Dataframe's missing values", function() local a = Dataframe(specs_dir.."/data/advanced_short.csv") a.dataset['Col A'][3] = nil local cnt, tot = a:count_na{as_dataframe = false} assert.are.same(cnt, {["Col A"]= 1, ["Col B"]= 0, ["Col C"]=1}) assert.are.same(tot, 2) a:fill_all_na(-1) assert.are.same(a:count_na{as_dataframe = false}, {["Col A"]= 0, ["Col B"]= 0, ["Col C"]=0}) assert.are.same(a:get_column('Col A'), {1,2,-1}) end) it("The count_na should #1 return a Dataframe by default", function() local a = Dataframe(specs_dir.."/data/advanced_short.csv") local ret = a:count_na() assert.are.same(torch.type(ret), "Dataframe") assert.are.same(ret:size(), 3, "3 columns should render 3 rows") end) end)
mit
drmingdrmer/mysql-proxy-xp
lib/admin.lua
3
2741
--[[ $%BEGINLICENSE%$ Copyright (c) 2008, 2009, 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%$ --]] function set_error(errmsg) proxy.response = { type = proxy.MYSQLD_PACKET_ERR, errmsg = errmsg or "error" } end function read_query(packet) if packet:byte() ~= proxy.COM_QUERY then set_error("[admin] we only handle text-based queries (COM_QUERY)") return proxy.PROXY_SEND_RESULT end local query = packet:sub(2) local rows = { } local fields = { } if query:lower() == "select * from backends" then fields = { { name = "backend_ndx", type = proxy.MYSQL_TYPE_LONG }, { name = "address", type = proxy.MYSQL_TYPE_STRING }, { name = "state", type = proxy.MYSQL_TYPE_STRING }, { name = "type", type = proxy.MYSQL_TYPE_STRING }, { name = "uuid", type = proxy.MYSQL_TYPE_STRING }, { name = "connected_clients", type = proxy.MYSQL_TYPE_LONG }, } for i = 1, #proxy.global.backends do local states = { "unknown", "up", "down" } local types = { "unknown", "rw", "ro" } local b = proxy.global.backends[i] rows[#rows + 1] = { i, b.dst.name, -- configured backend address states[b.state + 1], -- the C-id is pushed down starting at 0 types[b.type + 1], -- the C-id is pushed down starting at 0 b.uuid, -- the MySQL Server's UUID if it is managed b.connected_clients -- currently connected clients } end elseif query:lower() == "select * from help" then fields = { { name = "command", type = proxy.MYSQL_TYPE_STRING }, { name = "description", type = proxy.MYSQL_TYPE_STRING }, } rows[#rows + 1] = { "SELECT * FROM help", "shows this help" } rows[#rows + 1] = { "SELECT * FROM backends", "lists the backends and their state" } else set_error("use 'SELECT * FROM help' to see the supported commands") return proxy.PROXY_SEND_RESULT end proxy.response = { type = proxy.MYSQLD_PACKET_OK, resultset = { fields = fields, rows = rows } } return proxy.PROXY_SEND_RESULT end
gpl-2.0
gvx/space
shipgraphics/light_scout.lua
1
1570
return { {width=1.5,-0.305,-0.419,-0.347,-0.417,-0.352,-0.208,-0.295,-0.003,-0.224,0.162,-0.115,0.34,-0.043,0.342}, {width=1.5,0.103,-0.69,-0.109,-0.689}, {width=1.5,0.082,-0.626,-0.083,-0.624}, {width=1.5,-0.342,-0.627,-0.517,-0.626}, {width=1.5,-0.318,-0.692,-0.539,-0.694}, {width=1.5,-0.31,-0.057,-0.686,-0.288,-1,-0.376,-0.996,-0.491,-0.686,-0.58,-0.514,-0.576,-0.514,-0.623,-0.566,-0.762,-0.501,-0.806,-0.374,-0.806,-0.289,-0.766,-0.336,-0.623,-0.336,-0.578,-0.304,-0.55,-0.306,-0.418,-0.215,-0.418,-0.158,-0.525,-0.084,-0.573,-0.084,-0.62,-0.132,-0.759,-0.053,-0.798,0.053,-0.798,0.132,-0.759,0.084,-0.62,0.084,-0.573,0.158,-0.525,0.215,-0.418,0.305,-0.418,0.304,-0.55,0.336,-0.578,0.336,-0.623,0.289,-0.766,0.373,-0.806,0.501,-0.806,0.566,-0.762,0.514,-0.623,0.514,-0.576,0.686,-0.58,0.996,-0.491,1,-0.376,0.686,-0.288,0.31,-0.057}, {width=1.5,0.305,-0.419,0.347,-0.417,0.352,-0.208,0.295,-0.003,0.224,0.162,0.115,0.34,0.042,0.342}, {width=1.5,-0.085,0.342,-0.049,0.454,-0.145,0.454,-0.259,0.483,-0.261,0.523,-0.143,0.568,-0.03,0.649,-0.023,0.78,-0,0.806,0.023,0.78,0.03,0.649,0.143,0.568,0.261,0.523,0.259,0.483,0.144,0.454,0.049,0.454,0.085,0.342}, {width=1.5,-0.039,0.641,-0.038,-0.045,-0.162,-0.228,-0.162,-0.419,-0.109,-0.488,-0.031,-0.525,0.031,-0.525,0.109,-0.488,0.162,-0.419,0.162,-0.228,0.038,-0.045,0.039,0.641}, {width=1.5,0.342,-0.627,0.517,-0.626}, {width=1.5,0.318,-0.692,0.539,-0.694}, collision = {-0,0.804,-0.262,0.522,-0.311,-0.059,-1,-0.376,-0.997,-0.492,-0.502,-0.806,0.502,-0.806,0.997,-0.492,1,-0.376,0.311,-0.059,0.262,0.522,-0,0.804}, }
mit
paladiyom/paladerz
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
anshkumar/yugioh-glaze
assets/script/c41753322.lua
3
3301
--竜脚獣ブラキオン function c41753322.initial_effect(c) --cannot special summon local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_SINGLE_RANGE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetRange(LOCATION_DECK) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --summon with 1 tribute local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(41753322,0)) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_SUMMON_PROC) e2:SetCondition(c41753322.otcon) e2:SetOperation(c41753322.otop) e2:SetValue(SUMMON_TYPE_ADVANCE) c:RegisterEffect(e2) --turn set local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(41753322,1)) e3:SetCategory(CATEGORY_POSITION) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_MZONE) e3:SetTarget(c41753322.postg) e3:SetOperation(c41753322.posop) c:RegisterEffect(e3) --position local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(41753322,1)) e4:SetCategory(CATEGORY_POSITION) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e4:SetCode(EVENT_FLIP_SUMMON_SUCCESS) e4:SetTarget(c41753322.postg2) e4:SetOperation(c41753322.posop2) c:RegisterEffect(e4) --damage amp local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e5:SetRange(LOCATION_MZONE) e5:SetCode(EVENT_PRE_BATTLE_DAMAGE) e5:SetCondition(c41753322.dcon) e5:SetOperation(c41753322.dop) c:RegisterEffect(e5) end function c41753322.otfilter(c,tp) return c:IsRace(RACE_DINOSAUR) and (c:IsControler(tp) or c:IsFaceup()) end function c41753322.otcon(e,c) if c==nil then return true end local tp=c:GetControler() local mg=Duel.GetMatchingGroup(c41753322.otfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,tp) return c:GetLevel()>6 and Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.GetTributeCount(c,mg)>0 end function c41753322.otop(e,tp,eg,ep,ev,re,r,rp,c) local mg=Duel.GetMatchingGroup(c41753322.otfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,tp) local sg=Duel.SelectTribute(tp,c,1,1,mg) c:SetMaterial(sg) Duel.Release(sg,REASON_SUMMON+REASON_MATERIAL) end function c41753322.postg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsCanTurnSet() and c:GetFlagEffect(41753322)==0 end c:RegisterFlagEffect(41753322,RESET_EVENT+0x1fc0000+RESET_PHASE+PHASE_END,0,1) Duel.SetOperationInfo(0,CATEGORY_POSITION,c,1,0,0) end function c41753322.posop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() then Duel.ChangePosition(c,POS_FACEDOWN_DEFENCE) end end function c41753322.postg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end local g=Duel.GetMatchingGroup(Card.IsCanTurnSet,tp,LOCATION_MZONE,LOCATION_MZONE,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_POSITION,g,g:GetCount(),0,0) end function c41753322.posop2(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsCanTurnSet,tp,LOCATION_MZONE,LOCATION_MZONE,e:GetHandler()) Duel.ChangePosition(g,POS_FACEDOWN_DEFENCE) end function c41753322.dcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return ep~=tp and Duel.GetAttackTarget()==c end function c41753322.dop(e,tp,eg,ep,ev,re,r,rp) Duel.ChangeBattleDamage(ep,ev*2) end
gpl-2.0
Arashbrsh/kings-BOT
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
aminsa2000/perfect
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
paladiyom/paladerz
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
anshkumar/yugioh-glaze
assets/script/c35686187.lua
3
1145
--断頭台の惨劇 function c35686187.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHANGE_POS) e1:SetCondition(c35686187.condition) e1:SetTarget(c35686187.target) e1:SetOperation(c35686187.activate) c:RegisterEffect(e1) end function c35686187.cfilter(c,tp) return c:IsControler(tp) and c:IsPreviousPosition(POS_FACEUP_ATTACK) and c:IsPosition(POS_FACEUP_DEFENCE) end function c35686187.condition(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c35686187.cfilter,1,nil,1-tp) end function c35686187.filter(c) return c:IsDefencePos() and c:IsDestructable() end function c35686187.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c35686187.filter,tp,0,LOCATION_MZONE,1,nil) end local g=Duel.GetMatchingGroup(c35686187.filter,tp,0,LOCATION_MZONE,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c35686187.activate(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c35686187.filter,tp,0,LOCATION_MZONE,nil) if g:GetCount()>0 then Duel.Destroy(g,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c75886890.lua
3
3138
--ヴァイロン・スフィア function c75886890.initial_effect(c) --equip local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(75886890,0)) e1:SetCategory(CATEGORY_EQUIP) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) e1:SetCode(EVENT_TO_GRAVE) e1:SetCondition(c75886890.eqcon) e1:SetCost(c75886890.eqcost) e1:SetTarget(c75886890.eqtg) e1:SetOperation(c75886890.eqop) c:RegisterEffect(e1) --equip2 local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(75886890,1)) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCategory(CATEGORY_EQUIP) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_SZONE) e2:SetCost(c75886890.eqcost2) e2:SetTarget(c75886890.eqtg2) e2:SetOperation(c75886890.eqop2) c:RegisterEffect(e2) end function c75886890.eqcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:GetPreviousLocation()==LOCATION_MZONE end function c75886890.eqcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckLPCost(tp,500) end Duel.PayLPCost(tp,500) end function c75886890.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,nil) end function c75886890.eqop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.Equip(tp,c,tc) --equip limit local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetValue(c75886890.eqlimit) e1:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e1) end end function c75886890.eqlimit(e,c) return c:GetControler()==e:GetHandlerPlayer() or e:GetHandler():GetEquipTarget()==c end function c75886890.eqcost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end e:SetLabelObject(e:GetHandler():GetEquipTarget()) Duel.SendtoGrave(e:GetHandler(),REASON_COST) end function c75886890.filter2(c,ec) return c:IsType(TYPE_EQUIP) and c:CheckEquipTarget(ec) end function c75886890.eqtg2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local ec=e:GetHandler():GetEquipTarget() if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c75886890.filter2(chkc,ec) end if chk==0 then return ec and Duel.IsExistingTarget(c75886890.filter2,tp,LOCATION_GRAVE,0,1,nil,ec) end Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(75886890,2)) Duel.SelectTarget(tp,c75886890.filter2,tp,LOCATION_GRAVE,0,1,1,nil,e:GetLabelObject()) e:GetLabelObject():CreateEffectRelation(e) end function c75886890.eqop2(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() local ec=e:GetLabelObject() if tc:IsRelateToEffect(e) and ec:IsFaceup() and ec:IsRelateToEffect(e) then Duel.Equip(tp,tc,ec) end end
gpl-2.0
Mordonus/RaidOps
RaidOps/EPGP.lua
1
45534
----------------------------------------------------------------------------------------------- -- Client Lua Script for RaidOps -- Copyright (c) Piotr Szymczak 2015 dogier140@poczta.fm. ----------------------------------------------------------------------------------------------- local DKP = Apollo.GetAddon("RaidOps") local defaultSlotValues = { ["Weapon"] = 1, ["Shield"] = 0.777, ["Head"] = 1, ["Shoulders"] = 0.777, ["Chest"] = 1, ["Hands"] = 0.777, ["Legs"] = 1, ["Attachment"] = 0.7, ["Gadget"] = 0.55, ["Implant"] = 0.7, ["Feet"] = 0.777, ["Support"] = 0.7 } local defaultQualityValues = { ["White"] = 1, ["Green"] = .5, ["Blue"] = .33, ["Purple"] = .15, ["Orange"] = .1, ["Pink"] = .05 } local DataScapeTokenIds = { ["Chest"] = 69892, ["Legs"] = 69893, ["Head"] = 69894, ["Shoulders"] = 69895, ["Hands"] = 69896, ["Feet"] = 69897, } local GeneticTokenIds = { ["Chest"] = 69814, ["Legs"] = 69815, ["Head"] = 69816, ["Shoulders"] = 69817, ["Hands"] = 69818, ["Feet"] = 69819, } local ktUndoActions = { ["raep"] = "{Raid EP Award}", ["ragp"] = "{Raid GP Award}", ["epgpd"] = "{EP GP Decay}", ["epd"] = "{EP Decay}", ["gpd"] = "{GP Decay}", } -- constants from ETooltip local kUIBody = "ff39b5d4" local nItemIDSpacing = 4 function DKP:EPGPInit() self.wndEPGPSettings = Apollo.LoadForm(self.xmlDoc2,"RDKP/EPGP",nil,self) self.wndEPGPSettings:Show(false,true) self.GeminiLocale:TranslateWindow(self.Locale, self.wndEPGPSettings) if self.tItems["EPGP"] == nil or self.tItems["EPGP"].SlotValues == nil then self.tItems["EPGP"] = {} self.tItems["EPGP"].SlotValues = defaultSlotValues self.tItems["EPGP"].QualityValues = defaultQualityValues self.tItems["EPGP"].Enable = 1 self.tItems["EPGP"].FormulaModifier = 0.5 self.tItems["EPGP"].BaseGP = 1 self.tItems["EPGP"].MinEP = 100 end if self.tItems["EPGP"].bDecayEP == nil then self.tItems["EPGP"].bDecayEP = false end if self.tItems["EPGP"].bDecayGP == nil then self.tItems["EPGP"].bDecayGP = false end if self.tItems["EPGP"].nDecayValue == nil then self.tItems["EPGP"].nDecayValue = 25 end if self.tItems["EPGP"].bDecayRealGP == nil then self.tItems["EPGP"].bDecayRealGP = false end if self.tItems["EPGP"].bMinGP == nil then self.tItems["EPGP"].bMinGP = false end if self.tItems["EPGP"].bDecayPrec == nil then self.tItems["EPGP"].bDecayPrec = false end if self.tItems["EPGP"].bMinGPThres == nil then self.tItems["EPGP"].bMinGPThres = false end if self.tItems["EPGP"].QualityValuesAbove == nil then self.tItems["EPGP"].QualityValuesAbove = defaultQualityValues end if self.tItems["EPGP"].SlotValuesAbove == nil then self.tItems["EPGP"].SlotValuesAbove = defaultSlotValues end if self.tItems["EPGP"].FormulaModifierAbove == nil then self.tItems["EPGP"].FormulaModifierAbove = 0.5 end if self.tItems["EPGP"].nItemPowerThresholdValue == nil then self.tItems["EPGP"].nItemPowerThresholdValue = 0 end if self.tItems["EPGP"].bUseItemLevelForGPCalc == nil then self.tItems["EPGP"].bUseItemLevelForGPCalc = false end if self.tItems["EPGP"].bStaticGPCalc == nil then self.tItems["EPGP"].bStaticGPCalc = false end if self.tItems["EPGP"].bCalcForUnequippable == nil then self.tItems["EPGP"].bCalcForUnequippable = false end if self.tItems["EPGP"].nUnequippableSlotValue == nil then self.tItems["EPGP"].nUnequippableSlotValue = 1 end if not self.tItems["EPGP"].QualityValuesAbove["Pink"] then self.tItems["EPGP"].QualityValuesAbove["Pink"] = defaultQualityValues["Pink"] end if not self.tItems["EPGP"].QualityValues["Pink"] then self.tItems["EPGP"].QualityValues["Pink"] = defaultQualityValues["Pink"] end self.wndEPGPSettings:FindChild("DecayValue"):SetText(self.tItems["EPGP"].nDecayValue) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayValue"):SetText(self.tItems["EPGP"].nDecayValue) self.wndEPGPSettings:FindChild("DecayEP"):SetCheck(self.tItems["EPGP"].bDecayEP) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayEP"):SetCheck(self.tItems["EPGP"].bDecayEP) self.wndEPGPSettings:FindChild("DecayGP"):SetCheck(self.tItems["EPGP"].bDecayGP) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayGP"):SetCheck(self.tItems["EPGP"].bDecayGP) self.wndEPGPSettings:FindChild("DecayRealGP"):SetCheck(self.tItems["EPGP"].bDecayRealGP) self.wndEPGPSettings:FindChild("DecayPrecision"):SetCheck(self.tItems["EPGP"].bDecayPrec) self.wndEPGPSettings:FindChild("GPMinimum1"):SetCheck(self.tItems["EPGP"].bMinGP) self.wndEPGPSettings:FindChild("GPDecayThreshold"):SetCheck(self.tItems["EPGP"].bMinGPThres) self.wndEPGPSettings:FindChild("ItemLevelForGPCalc"):SetCheck(self.tItems["EPGP"].bUseItemLevelForGPCalc) self.wndEPGPSettings:FindChild("StaticGPCalc"):SetCheck(self.tItems["EPGP"].bStaticGPCalc) self.wndEPGPSettings:FindChild("CalcForUneq"):SetCheck(self.tItems["EPGP"].bCalcForUnequippable) self.wndEPGPSettings:FindChild("SlotValueUneq"):FindChild("Field"):SetText(self.tItems["EPGP"].nUnequippableSlotValue) self:EPGPFillInSettings() self:EPGPChangeUI() --Apollo.RegisterEventHandler("ItemLink", "OnLootedItem", self) end function DKP:EPGPItemLevelGPCalcEnable() self.tItems["EPGP"].bUseItemLevelForGPCalc = true self.tItems["EPGP"].bStaticGPCalc = false self:EPGPAdjustFormulaDisplay() end function DKP:EPGPItemLevelGPCalcDisable() self.tItems["EPGP"].bUseItemLevelForGPCalc = false self:EPGPAdjustFormulaDisplay() end function DKP:EPGPStaticGPCalcEnable() self.tItems["EPGP"].bUseItemLevelForGPCalc = false self.tItems["EPGP"].bStaticGPCalc = true self:EPGPAdjustFormulaDisplay() end function DKP:EPGPStaticGPCalcDisable() self.tItems["EPGP"].bStaticGPCalc = false self:EPGPAdjustFormulaDisplay() end function DKP:EPGPCalcUneqEnable() self.tItems["EPGP"].bCalcForUnequippable = true end function DKP:EPGPCalcUneqDisable() self.tItems["EPGP"].bCalcForUnequippable = false end function DKP:EPGPItemSlotValueUneqChanged(wndHandler,wndControl,strText) local val = tonumber(strText) if val then self.tItems["EPGP"].nUnequippableSlotValue = val else wndControl:SetText(self.tItems["EPGP"].nUnequippableSlotValue) end end function DKP:EPGPSetPowerThreshold(wndHandler,wndControl,strText) local val = tonumber(strText) if val and val > 0 then self.tItems["EPGP"].nItemPowerThresholdValue = val else self.tItems["EPGP"].nItemPowerThresholdValue = 0 wndControl:SetText("--") end if self.tItems["EPGP"].nItemPowerThresholdValue == 0 then self.wndEPGPSettings:FindChild("ItemCostAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("OrangeQualAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("PurpleQualAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("PinkQualAbove"):SetOpacity(0.5) else self.wndEPGPSettings:FindChild("ItemCostAbove"):SetOpacity(1) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetOpacity(1) self.wndEPGPSettings:FindChild("OrangeQualAbove"):SetOpacity(1) self.wndEPGPSettings:FindChild("PurpleQualAbove"):SetOpacity(1) self.wndEPGPSettings:FindChild("PinkQualAbove"):SetOpacity(1) end end function DKP:OnLootedItem(item,bSuspend) self.ItemDatabase[item:GetName()] = {} self.ItemDatabase[item:GetName()].ID = item:GetItemId() self.ItemDatabase[item:GetName()].quality = item:GetItemQuality() self.ItemDatabase[item:GetName()].strChat = item:GetChatLinkString() self.ItemDatabase[item:GetName()].sprite = item:GetIcon() self.ItemDatabase[item:GetName()].strItem = item:GetName() self.ItemDatabase[item:GetName()].Power = item:GetItemPower() if item:GetSlotName() ~= "" then self.ItemDatabase[item:GetName()].slot = item:GetSlotName() else self.ItemDatabase[item:GetName()].slot = item:GetSlot() end --if item:GetSlotName() == nil then self.ItemDatabase[item:GetName()] = nil end if not bSuspend then Event_FireGenericEvent("GenericEvent_LootChannelMessage", String_GetWeaselString(Apollo.GetString("CRB_MasterLoot_AssignMsg"), item:GetName(),self.tItems[math.random(1,10)].strName)) end end function DKP:EPGPGetTokenItemID(strToken) if string.find(strToken,self.Locale["#Calculated"]) or string.find(strToken,self.Locale["#Algebraic"]) or string.find(strToken,self.Locale["#Logarithmic"]) then --DS if string.find(strToken,self.Locale["#Chestplate"]) then return DataScapeTokenIds["Chest"] elseif string.find(strToken,self.Locale["#Greaves"]) then return DataScapeTokenIds["Legs"] elseif string.find(strToken,self.Locale["#Helm"]) then return DataScapeTokenIds["Head"] elseif string.find(strToken,self.Locale["#Pauldron"]) then return DataScapeTokenIds["Shoulders"] elseif string.find(strToken,self.Locale["#Glove"]) then return DataScapeTokenIds["Hands"] elseif string.find(strToken,self.Locale["#Boot"]) then return DataScapeTokenIds["Feet"] end elseif string.find(strToken,self.Locale["#Xenological"]) or string.find(strToken,self.Locale["#Xenobiotic"]) or string.find(strToken,self.Locale["#Xenogenetic"]) then --GA if string.find(strToken,self.Locale["#Chestplate"]) then return GeneticTokenIds["Chest"] elseif string.find(strToken,self.Locale["#Greaves"]) then return GeneticTokenIds["Legs"] elseif string.find(strToken,self.Locale["#Helm"]) then return GeneticTokenIds["Head"] elseif string.find(strToken,self.Locale["#Pauldron"]) then return GeneticTokenIds["Shoulders"] elseif string.find(strToken,self.Locale["#Glove"]) then return GeneticTokenIds["Hands"] elseif string.find(strToken,self.Locale["#Boot"]) then return GeneticTokenIds["Feet"] end end end function DKP:EPGPDecayShow() self.wndMain:FindChild("EPGPDecay"):Show(true,false) self.wndMain:FindChild("Decay"):Show(false,false) self.wndMain:FindChild("DecayShow"):SetCheck(false) end function DKP:EPGPDecayHide() self.wndMain:FindChild("EPGPDecay"):Show(false,false) end function DKP:EPGPFillInSettings() self:EPGPFillInSettingsBelow() self:EPGPFillInSettingsAbove() if self.tItems["EPGP"].Enable == 1 then self.wndEPGPSettings:FindChild("Enable"):SetCheck(true) end if self.tItems["EPGP"].Tooltips == 1 then self.wndSettings:FindChild("ButtonShowGP"):SetCheck(true) self:EPGPHookToETooltip() end if self.tItems["EPGP"].nItemPowerThresholdValue == 0 then self.wndEPGPSettings:FindChild("ItemCostAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("OrangeQualAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("PurpleQualAbove"):SetOpacity(0.5) self.wndEPGPSettings:FindChild("PinkQualAbove"):SetOpacity(0.5) end self.wndEPGPSettings:FindChild("White"):SetText(self.tItems["EPGP"].QualityValues["White"]) self.wndEPGPSettings:FindChild("Green"):SetText(self.tItems["EPGP"].QualityValues["Green"]) self.wndEPGPSettings:FindChild("Blue"):SetText(self.tItems["EPGP"].QualityValues["Blue"]) self.wndEPGPSettings:FindChild("PowerLevelThreshold"):SetText(self.tItems["EPGP"].nItemPowerThresholdValue == 0 and "--" or self.tItems["EPGP"].nItemPowerThresholdValue) end function DKP:EPGPFillInSettingsBelow() --Slots self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Weapon"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue1"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Shield"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue2"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Head"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue3"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Shoulders"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue4"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Chest"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue5"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Hands"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue6"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Legs"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue7"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Feet"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue8"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Attachment"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue9"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Support"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue10"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Gadget"]) self.wndEPGPSettings:FindChild("ItemCostBelow"):FindChild("SlotValue11"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValues["Implant"]) --Rest self.wndEPGPSettings:FindChild("FormulaLabelBelow"):FindChild("CustomModifier"):SetText(self.tItems["EPGP"].FormulaModifier) self.wndEPGPSettings:FindChild("PurpleQualBelow"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValues["Purple"]) self.wndEPGPSettings:FindChild("OrangeQualBelow"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValues["Orange"]) self.wndEPGPSettings:FindChild("PinkQualBelow"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValues["Pink"]) self.wndEPGPSettings:FindChild("MinEP"):SetText(self.tItems["EPGP"].MinEP) self.wndEPGPSettings:FindChild("BaseGP"):SetText(self.tItems["EPGP"].BaseGP) end function DKP:EPGPFillInSettingsAbove() --Slots self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Weapon"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue1"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Shield"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue2"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Head"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue3"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Shoulders"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue4"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Chest"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue5"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Hands"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue6"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Legs"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue7"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Feet"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue8"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Attachment"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue9"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Support"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue10"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Gadget"]) self.wndEPGPSettings:FindChild("ItemCostAbove"):FindChild("SlotValue11"):FindChild("Field"):SetText(self.tItems["EPGP"].SlotValuesAbove["Implant"]) --Rest self.wndEPGPSettings:FindChild("FormulaLabelAbove"):FindChild("CustomModifier"):SetText(self.tItems["EPGP"].FormulaModifierAbove) self.wndEPGPSettings:FindChild("PurpleQualAbove"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValuesAbove["Purple"]) self.wndEPGPSettings:FindChild("OrangeQualAbove"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValuesAbove["Orange"]) self.wndEPGPSettings:FindChild("PinkQualAbove"):FindChild("Field"):SetText(self.tItems["EPGP"].QualityValuesAbove["Pink"]) self.wndEPGPSettings:FindChild("MinEP"):SetText(self.tItems["EPGP"].MinEP) self.wndEPGPSettings:FindChild("BaseGP"):SetText(self.tItems["EPGP"].BaseGP) end function DKP:EPGPGetSlotValueByString(strSlot) return self.tItems["EPGP"].SlotValues[strSlot] end function DKP:EPGPGetSlotStringByID(ID) if ID == 16 then return "Weapon" elseif ID == 7 then return "Attachment" elseif ID == 3 then return "Shoulders" elseif ID == 0 then return "Chest" elseif ID == 4 then return "Feet" elseif ID == 11 then return "Gadget" elseif ID == 5 then return "Hands" elseif ID == 2 then return "Head" elseif ID == 10 then return "Implant" elseif ID == 1 then return "Legs" elseif ID == 15 then return "Shield" elseif ID == 8 then return "Support" end end function DKP:EPGPGetSlotSpriteByQuality(ID) if ID == 5 then return "CRB_Tooltips:sprTooltip_SquareFrame_Purple" elseif ID == 6 then return "CRB_Tooltips:sprTooltip_SquareFrame_Orange" elseif ID == 4 then return "CRB_Tooltips:sprTooltip_SquareFrame_Blue" elseif ID == 3 then return "CRB_Tooltips:sprTooltip_SquareFrame_Green" elseif ID == 2 then return "CRB_Tooltips:sprTooltip_SquareFrame_White" else return "CRB_Tooltips:sprTooltip_SquareFrame_DarkModded" end end function DKP:EPGPGetSlotSpriteByQualityRectangle(ID) if ID == 5 then return "BK3:UI_BK3_ItemQualityPurple" elseif ID == 6 then return "BK3:UI_BK3_ItemQualityOrange" elseif ID == 4 then return "BK3:UI_BK3_ItemQualityBlue" elseif ID == 3 then return "BK3:UI_BK3_ItemQualityGreen" elseif ID == 2 then return "BK3:UI_BK3_ItemQualityWhite" else return "BK3:UI_BK3_ItemQualityGrey" end end --deprecated function DKP:EPGPGetItemCostByName(strItem) return math.ceil(self.ItemDatabase[strItem].Power/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(self.ItemDatabase[strItem].quality)] * self.tItems["EPGP"].FormulaModifier * self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(self.ItemDatabase[strItem].slot)]) end function DKP:EPGPDecayEPEnable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].bDecayEP = true self.wndEPGPSettings:FindChild("DecayEP"):SetCheck(true) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayEP"):SetCheck(true) end function DKP:EPGPDecayEPDisable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].bDecayEP = false self.wndEPGPSettings:FindChild("DecayEP"):SetCheck(false) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayEP"):SetCheck(false) end function DKP:EPGPDecayPrecEnable() self.tItems["EPGP"].bDecayPrec = true end function DKP:EPGPDecayPrecDisable() self.tItems["EPGP"].bDecayPrec = false end function DKP:EPGPDecayGPEnable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].bDecayGP = true self.wndEPGPSettings:FindChild("DecayGP"):SetCheck(true) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayGP"):SetCheck(true) end function DKP:EPGPDecayGPDisable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].bDecayGP = false self.wndEPGPSettings:FindChild("DecayGP"):SetCheck(false) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayGP"):SetCheck(false) end function DKP:EPGPChangeUI() if self.tItems["EPGP"].Enable == 1 then --Main Controls local controls = self.wndMain:FindChild("Controls") controls:FindChild("EditBox1"):SetText("Input Value") --input controls:FindChild("EditBox"):SetAnchorOffsets(25,98,187,144) -- comment controls:FindChild("ButtonEP"):Show(true,false) controls:FindChild("ButtonGP"):Show(true,false) self.wndEPGPSettings:FindChild("DecayNow"):Enable(true) self.wndSettings:FindChild("ButtonShowGP"):Enable(true) else --Main Controls local controls = self.wndMain:FindChild("Controls") controls:FindChild("EditBox1"):SetText("Input Value") --input controls:FindChild("EditBox"):SetAnchorOffsets(25,67,187,146) -- comment controls:FindChild("ButtonEP"):Show(false,false) controls:FindChild("ButtonGP"):Show(false,false) self.wndEPGPSettings:FindChild("DecayNow"):Enable(false) self.wndSettings:FindChild("ButtonShowGP"):Enable(false) if self:IsHooked(Apollo.GetAddon("ETooltip"),"AttachBelow") then self:Unhook(Apollo.GetAddon("ETooltip"),"AttachBelow") end end self:EPGPAdjustFormulaDisplay() end function DKP:EPGPAdjustFormulaDisplay() if self.tItems["EPGP"].bUseItemLevelForGPCalc then self.wndEPGPSettings:FindChild("FormulaLabelBelow"):SetText(self.Locale["#wndEPGPSettings:ItemCost:FormulaAlt"]) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetText(self.Locale["#wndEPGPSettings:ItemCost:FormulaAlt"]) self.wndEPGPSettings:FindChild("FormulaLabelBelow"):FindChild("CustomModifier"):SetAnchorOffsets(279,3,334,36) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):FindChild("CustomModifier"):SetAnchorOffsets(279,3,334,36) elseif self.tItems["EPGP"].bStaticGPCalc then self.wndEPGPSettings:FindChild("FormulaLabelBelow"):SetText(self.Locale["#wndEPGPSettings:ItemCost:FormulaStatic"]) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetText(self.Locale["#wndEPGPSettings:ItemCost:FormulaStatic"]) self.wndEPGPSettings:FindChild("FormulaLabelBelow"):FindChild("CustomModifier"):SetAnchorOffsets(363,3,418,36) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):FindChild("CustomModifier"):SetAnchorOffsets(363,3,418,36) else self.wndEPGPSettings:FindChild("FormulaLabelBelow"):SetText(self.Locale["#wndEPGPSettings:ItemCost:Formula"]) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):SetText(self.Locale["#wndEPGPSettings:ItemCost:Formula"]) self.wndEPGPSettings:FindChild("FormulaLabelBelow"):FindChild("CustomModifier"):SetAnchorOffsets(279,3,334,36) self.wndEPGPSettings:FindChild("FormulaLabelAbove"):FindChild("CustomModifier"):SetAnchorOffsets(279,3,334,36) end end function DKP:EPGPReset() self.tItems["EPGP"].SlotValues = defaultSlotValues self.tItems["EPGP"].QualityValues = defaultQualityValues self.tItems["EPGP"].FormulaModifier = 0.5 self:ShowAll() self:EPGPFillInSettings() end function DKP:EPGPAdd(strName,EP,GP) EP = tonumber(EP) or 0 GP = tonumber(GP) or 0 local ID = self:GetPlayerByIDByName(strName) if ID ~= -1 then if EP ~= nil then self.tItems[ID].EP = self.tItems[ID].EP + EP end if GP ~= nil then self.tItems[ID].nAwardedGP = self.tItems[ID].nAwardedGP + GP end if self.tItems["EPGP"].bMinGP and self.tItems[ID].GP < 1 then self.tItems[ID].nAwardedGP = 1 elseif self.tItems["EPGP"].bMinGPThres and self.tItems[ID].GP < self.tItems[ID].nBaseGP then self.tItems[ID].nAwardedGP = self.tItems[ID].nBaseGP end end end function DKP:EPGPSubtract(strName,EP,GP) EP = tonumber(EP) or 0 GP = tonumber(GP) or 0 local ID = self:GetPlayerByIDByName(strName) if ID ~= -1 then if EP ~= nil then self.tItems[ID].EP = self.tItems[ID].EP - EP if self.tItems[ID].EP < self.tItems["EPGP"].MinEP then self.tItems[ID].EP = self.tItems["EPGP"].MinEP end end if GP ~= nil then self.tItems[ID].nAwardedGP = self.tItems[ID].nAwardedGP - GP end if self.tItems["EPGP"].bMinGP and self.tItems[ID].GP < 1 then self.tItems[ID].nAwardedGP = 1 elseif self.tItems["EPGP"].bMinGPThres and self.tItems[ID].GP < self.tItems[ID].nBaseGP then self.tItems[ID].nAwardedGP = self.tItems[ID].nBaseGP end end end function DKP:EPGPSet(strName,EP,GP) local ID = self:GetPlayerByIDByName(strName) if ID ~= -1 then if EP ~= nil then self.tItems[ID].EP = EP if self.tItems[ID].EP < self.tItems["EPGP"].MinEP then self.tItems[ID].EP = self.tItems["EPGP"].MinEP end end if GP ~= nil then self.tItems[ID].nAwardedGP = GP - self.tItems[ID].nBaseGP end if self.tItems["EPGP"].bMinGP and self.tItems[ID].GP < 1 then self.tItems[ID].nAwardedGP = 1 elseif self.tItems["EPGP"].bMinGPThres and self.tItems[ID].GP < self.tItems[ID].nBaseGP then self.tItems[ID].nAwardedGP = self.tItems[ID].nBaseGP end end end function DKP:EPGPAwardRaid(EP,GP) local tMembers = {} for i=1,GroupLib.GetMemberCount() do local member = GroupLib.GetGroupMember(i) if member ~= nil then local ID = self:GetPlayerByIDByName(member.strCharacterName) if ID ~= -1 then if self.tItems["settings"].bTrackUndo then table.insert(tMembers,self.tItems[ID]) end if EP ~= nil then self.tItems[ID].EP = self.tItems[ID].EP + EP if self.tItems[ID].EP < self.tItems["EPGP"].MinEP then self.tItems[ID].EP = self.tItems["EPGP"].MinEP end end if GP ~= nil then self.tItems[ID].nAwardedGP = self.tItems[ID].nAwardedGP + GP end end end end local strType if EP then strType = ktUndoActions["raep"] elseif GP then strType = ktUndoActions["ragp"] end if self.tItems["settings"].bTrackUndo and tMembers then self:UndoAddActivity(strType,EP or GP,tMembers) end self:ShowAll() end function DKP:EPGPCheckTresholds() for k , player in ipairs(self.tItems) do if player.EP < self.tItems["EPGP"].MinEP then player.EP = self.tItems["EPGP"].MinEP end if self.tItems["EPGP"].bMinGP and player.GP < 1 then player.nAwardedGP = 1 end if self.tItems["EPGP"].bMinGPThres and player.GP < player.nBaseGP then player.nAwardedGP = 0 end end end --------------------------------------------------------------------------------------------------- -- CostList Functions --------------------------------------------------------------------------------------------------- function DKP:EPGPGetQualityStringByID(ID) if ID == 5 then return "Purple" elseif ID == 6 then return "Orange" elseif ID == 4 then return "Blue" elseif ID == 3 then return "Green" elseif ID == 2 then return "White" elseif ID == 1 then return "Gray" elseif ID == 7 then return "Pink" end end --------------------------------------------------------------------------------------------------- -- RDKP/EPGP Functions --------------------------------------------------------------------------------------------------- function DKP:EPGPEnable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].Enable = 1 self:EPGPChangeUI() end function DKP:EPGPDisable( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].Enable = 0 self:EPGPChangeUI() end function DKP:EPGPDecay( wndHandler, wndControl, eMouseButton ) if self.tItems["settings"].bTrackUndo then local tMembers = {} for k,player in ipairs(self.tItems) do if self.tItems["Standby"][string.lower(player.strName)] == nil then table.insert(tMembers,player) end end local strType = "" if self.tItems["EPGP"].bDecayEP and self.tItems["EPGP"].bDecayGP then strType = ktUndoActions["epgpd"] elseif self.tItems["EPGP"].bDecayEP then strType = ktUndoActions["epd"] elseif self.tItems["EPGP"].bDecayGP then strType = ktUndoActions["gpd"] end self:UndoAddActivity(strType,self.tItems["EPGP"].nDecayValue.."%",tMembers) end for i=1,table.maxn(self.tItems) do if self.tItems[i] ~= nil and self.tItems["Standby"][string.lower(self.tItems[i].strName)] == nil then if self.tItems["EPGP"].bDecayPrec then self.tItems[i].EP = tonumber(string.format("%."..tostring(self.tItems["settings"].PrecisionEPGP).."f",self.tItems[i].EP)) self.tItems[i].nAwardedGP = tonumber(string.format("%."..tostring(self.tItems["settings"].PrecisionEPGP).."f",self.tItems[i].nAwardedGP)) end if self.wndEPGPSettings:FindChild("DecayEP"):IsChecked() == true then local nPreEP = self.tItems[i].EP self.tItems[i].EP = self.tItems[i].EP * ((100 - self.tItems["EPGP"].nDecayValue)/100) if self.tItems["settings"].logs == 1 then self:DetailAddLog(self.tItems["EPGP"].nDecayValue .. "% EP Decay","{Decay}",math.floor((nPreEP - self.tItems[i].EP)) * -1 ,i) end end if self.wndEPGPSettings:FindChild("DecayGP"):IsChecked() == true then local nPreGP = self.tItems[i].GP if self.tItems["EPGP"].bDecayRealGP then self.tItems[i].nAwardedGP = self.tItems[i].nAwardedGP * ((100 - self.tItems["EPGP"].nDecayValue)/100) else self.tItems[i].nAwardedGP = (self.tItems[i].GP * ((100 - self.tItems["EPGP"].nDecayValue)/100)) - self.tItems[i].nBaseGP end if self.tItems["settings"].logs == 1 then self:DetailAddLog(self.tItems["EPGP"].nDecayValue .. "% GP Decay","{Decay}",math.floor((nPreGP - self.tItems[i].GP)) * -1 ,i) end end end end self:DROnDecay() self:EPGPCheckTresholds() self:ShowAll() end function DKP:EPGPCheckDecayValue( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then local val = tonumber(strText) if val >= 1 and val <= 100 then self.tItems["EPGP"].nDecayValue = val self.wndEPGPSettings:FindChild("DecayValue"):SetText(val) self.wndMain:FindChild("EPGPDecay"):FindChild("DecayValue"):SetText(val) else wndControl:SetText(self.tItems["EPGP"].nDecayValue) end else wndControl:SetText(self.tItems["EPGP"].nDecayValue) end end function DKP:EPGPClose( wndHandler, wndControl, eMouseButton ) self.wndEPGPSettings:Show(false,false) end function DKP:EPGPSetCustomModifier( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then if wndControl:GetParent():GetName() == "FormulaLabelBelow" then self.tItems["EPGP"].FormulaModifier = tonumber(strText) else self.tItems["EPGP"].FormulaModifierAbove = tonumber(strText) end else if wndControl:GetParent():GetName() == "FormulaLabelBelow" then wndControl:SetText(self.tItems["EPGP"].FormulaModifier) else wndControl:SetText(self.tItems["EPGP"].FormulaModifierAbove) end end end function DKP:EPGPItemSlotValueChanged( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then if wndControl:GetParent():GetParent():GetName() == "ItemCostAbove" then self.tItems["EPGP"].SlotValuesAbove[wndControl:GetParent():FindChild("Name"):GetText()] = tonumber(strText) else self.tItems["EPGP"].SlotValues[wndControl:GetParent():FindChild("Name"):GetText()] = tonumber(strText) end else if wndControl:GetParent():GetParent():GetName() == "ItemCostAbove" then wndControl:SetText(self.tItems["EPGP"].SlotValuesAbove[wndControl:GetParent():FindChild("Name"):GetText()]) else wndControl:SetText(self.tItems["EPGP"].SlotValues[wndControl:GetParent():FindChild("Name"):GetText()]) end end end function DKP:EPGPShow( wndHandler, wndControl, eMouseButton ) self.wndEPGPSettings:Show(true,false) self.wndEPGPSettings:ToFront() end function DKP:EPGPItemQualityValueChanged( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then if string.find(wndControl:GetParent():GetName(),"Below") then if wndControl:GetParent():FindChild("Name"):GetText() == "Purple Quality" then self.tItems["EPGP"].QualityValues["Purple"] = tonumber(strText) else self.tItems["EPGP"].QualityValues["Orange"] = tonumber(strText) end else if wndControl:GetParent():FindChild("Name"):GetText() == "Purple Quality" then self.tItems["EPGP"].QualityValuesAbove["Purple"] = tonumber(strText) else self.tItems["EPGP"].QualityValuesAbove["Orange"] = tonumber(strText) end end else if string.find(wndControl:GetParent():GetName(),"Below") then if wndControl:GetParent():FindChild("Name"):GetText() == "Purple Quality" then wndControl:SetText(self.tItems["EPGP"].QualityValues["Purple"]) else wndControl:SetText(self.tItems["EPGP"].QualityValues["Orange"]) end else if wndControl:GetParent():FindChild("Name"):GetText() == "Purple Quality" then wndControl:SetText(self.tItems["EPGP"].QualityValuesAbove["Purple"]) else wndControl:SetText(self.tItems["EPGP"].QualityValuesAbove["Orange"]) end end end end function DKP:EPGPPinkItemQualityValueChanged(wndHandler,wndControl,strText) local val = tonumber(strText) if val then if string.find(wndControl:GetParent():GetName(),"Below") then self.tItems["EPGP"].QualityValues["Pink"] = val else self.tItems["EPGP"].QualityValuesAbove["Pink"] = val end else if string.find(wndControl:GetParent():GetName(),"Below") then wndControl:SetText(self.tItems["EPGP"].QualityValues["Pink"]) else wndControl:SetText(self.tItems["EPGP"].QualityValuesAbove["Pink"]) end end end function DKP:EPGPLesserQualityChanged(wndHandler,wndControl,strText) local val = tonumber(strText) if val then self.tItems["EPGP"].QualityValues[wndControl:GetName()] = val self.tItems["EPGP"].QualityValuesAbove[wndControl:GetName()] = val else wndControl:SetText(self.tItems["EPGP"].QualityValues[wndControl:GetName()]) end end function DKP:EPGPSetMinEP( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then self.tItems["EPGP"].MinEP = tonumber(strText) self:EPGPCheckTresholds() else wndControl:SetText(self.tItems["EPGP"].MinEP) end end function DKP:EPGPSetBaseGP( wndHandler, wndControl, strText ) if tonumber(strText) ~= nil then self.tItems["EPGP"].BaseGP = tonumber(strText) self:EPGPCheckTresholds() else wndControl:SetText(self.tItems["EPGP"].BaseGP) end end function DKP:EPGPGetItemCostByID(itemID,bCut) if not bCut then bCut = false end local item = Item.GetDataFromId(itemID) if string.find(item:GetName(),self.Locale["#Imprint"]) then item = Item.GetDataFromId(self:EPGPGetTokenItemID(item:GetName())) end if item and item:GetItemQuality() > 1 then if item:IsEquippable() then local slot slot = item:GetSlot() if self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)] == nil then return "" end if (item:GetDetailedInfo().tPrimary.nEffectiveLevel or 0) <= self.tItems["EPGP"].nItemPowerThresholdValue or self.tItems["EPGP"].nItemPowerThresholdValue == 0 then if not self.tItems["EPGP"].bStaticGPCalc then if not bCut then return " GP: " .. math.ceil((self.tItems["EPGP"].bUseItemLevelForGPCalc and item:GetDetailedInfo().tPrimary.nEffectiveLevel or item:GetItemPower())/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())] * self.tItems["EPGP"].FormulaModifier * self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]) else return math.ceil((self.tItems["EPGP"].bUseItemLevelForGPCalc and item:GetDetailedInfo().tPrimary.nEffectiveLevel or item:GetItemPower())/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())] * self.tItems["EPGP"].FormulaModifier * self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]) end else -- static if not bCut then return " GP: " .. math.ceil((self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())]) * self.tItems["EPGP"].FormulaModifier) else return math.ceil((self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())]) * self.tItems["EPGP"].FormulaModifier) end end else if not self.tItems["EPGP"].bStaticGPCalc then if not bCut then return " GP: " .. math.ceil((self.tItems["EPGP"].bUseItemLevelForGPCalc and item:GetDetailedInfo().tPrimary.nEffectiveLevel or item:GetItemPower())/self.tItems["EPGP"].QualityValuesAbove[self:EPGPGetQualityStringByID(item:GetItemQuality())] * self.tItems["EPGP"].FormulaModifierAbove * self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]) else return math.ceil((self.tItems["EPGP"].bUseItemLevelForGPCalc and item:GetDetailedInfo().tPrimary.nEffectiveLevel or item:GetItemPower())/self.tItems["EPGP"].QualityValuesAbove[self:EPGPGetQualityStringByID(item:GetItemQuality())] * self.tItems["EPGP"].FormulaModifierAbove * self.tItems["EPGP"].SlotValuesAbove[self:EPGPGetSlotStringByID(slot)]) end else -- static if not bCut then return " GP: " .. math.ceil((self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())]) * self.tItems["EPGP"].FormulaModifier) else return math.ceil((self.tItems["EPGP"].SlotValues[self:EPGPGetSlotStringByID(slot)]/self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())]) * self.tItems["EPGP"].FormulaModifier) end end end elseif self.tItems["EPGP"].bCalcForUnequippable then return math.ceil((self.tItems["EPGP"].nUnequippableSlotValue /self.tItems["EPGP"].QualityValues[self:EPGPGetQualityStringByID(item:GetItemQuality())]) * self.tItems["EPGP"].FormulaModifier) else return end else return "" end end function DKP:EPGPGetPRByName(strName) local ID = self:GetPlayerByIDByName(strName) if ID ~= -1 then if self.tItems[ID].GP ~= 0 then return string.format("%."..tostring(self.tItems["settings"].Precision).."f", self.tItems[ID].EP/(self.tItems[ID].GP)) else return "0" end else return "0" end end function DKP:EPGPGetPRByValues(nEP,nGP) if nGP ~= 0 then return tonumber(string.format("%."..tostring(self.tItems["settings"].Precision).."f", nEP/nGP)) else return 0 end end function DKP:EPGPGetPRByID(ID) if not self.tItems[ID] then return 0 end if ID ~= -1 then if self.tItems[ID].GP ~= 0 then return string.format("%."..tostring(self.tItems["settings"].Precision).."f", self.tItems[ID].EP/(self.tItems[ID].nAwardedGP + self.tItems[ID].nBaseGP)) else return "0" end else return "0" end end function DKP:EPGPDecayRealGPEnable() self.tItems["EPGP"].bDecayRealGP = true end function DKP:EPGPDecayRealGPDisable() self.tItems["EPGP"].bDecayRealGP = false end function DKP:EPGPMinGPEnable() self.tItems["EPGP"].bMinGP = true self:EPGPGPBaseThresDisable() for k ,player in ipairs(self.tItems) do if player.GP < 1 then player.nAwardedGP = 1 end end end function DKP:EPGPMinDisable() self.tItems["EPGP"].bMinGP = false self.wndEPGPSettings:FindChild("GPMinimum1"):SetCheck(false) end function DKP:EPGPGPBaseThresEnable() self.tItems["EPGP"].bMinGPThres = true self:EPGPMinDisable() for k ,player in ipairs(self.tItems) do if player.GP < player.nBaseGP then player.nAwardedGP = player.nBaseGP end end end function DKP:EPGPGPBaseThresDisable() self.tItems["EPGP"].bMinGPThres = false self.wndEPGPSettings:FindChild("GPDecayThreshold"):SetCheck(false) end -- Hook Part local failCounter = 0 function DKP:HookToTooltip(tContext) -- Based on EToolTip implementation if tContext.originalTootltipFunction then return end aAddon = Apollo.GetAddon("ToolTips") if not aAddon and failCounter < 10 then failCounter = failCounter + 1 self:delay(1,function(tContext) tContext:HookToTooltip(tContext) end) return elseif failCounter >= 10 then Print("Failed to hook to toltips addon.This should never occur unless you have addon that replaces tooltips.Notify me about that on github or curse :)") return end self.bPostInit = true tContext.originalTootltipFunction = Tooltip.GetItemTooltipForm local origCreateCallNames = aAddon.CreateCallNames if not origCreateCallNames then return end aAddon.CreateCallNames = function(luaCaller) origCreateCallNames(luaCaller) tContext.originalTootltipFunction = Tooltip.GetItemTooltipForm Tooltip.GetItemTooltipForm = function (luaCaller, wndControl, item, bStuff, nCount) return tContext.EnhanceItemTooltip(luaCaller, wndControl, item, bStuff, nCount) end end aAddon.CreateCallNames() end function DKP:EPGPHookToETooltip( wndHandler, wndControl, eMouseButton ) if not Apollo.GetAddon("ETooltip") then self.tItems["EPGP"].Tooltips = 1 self:delay(1,function(tContext) tContext:HookToTooltip(tContext) end) else if Apollo.GetAddon("ETooltip") == nil then self.tItems["EPGP"].Tooltips = 0 Print("Couldn't find EToolTip Addon") if wndControl ~= nil then wndControl:SetCheck(false) end return end if not Apollo.GetAddon("ETooltip").tSettings["bShowItemID"] then self.tItems["EPGP"].Tooltips = 0 Print("Enable option to Show item ID in EToolTip") if wndControl ~= nil then wndControl:SetCheck(false) end return end self.tItems["EPGP"].Tooltips = 1 if not self:IsHooked(Apollo.GetAddon("ETooltip"),"AttachBelow") then self:RawHook(Apollo.GetAddon("ETooltip"),"AttachBelow") end end end function DKP:EPGPUnHook( wndHandler, wndControl, eMouseButton ) self.tItems["EPGP"].Tooltips = 0 self:Unhook(Apollo.GetAddon("ETooltip"),"AttachBelow") if self.originalTootltipFunction then Tooltip.GetItemTooltipForm = self.originalTootltipFunction self.originalTootltipFunction = nil end end function DKP:EnhanceItemTooltip(wndControl,item,tOpt,nCount) local this = Apollo.GetAddon("RaidOps") wndControl:SetTooltipDoc(nil) local wndTooltip, wndTooltipComp = this.originalTootltipFunction(self, wndControl, item, tOpt, nCount) local wndTarget if wndTooltip then wndTarget = wndTooltip:FindChild("SeparatorDiagonal") and wndTooltip:FindChild("SeparatorDiagonal") or wndTooltip:FindChild("SeparatorSmallLine") end if wndTooltip and item and item:GetItemQuality() > 1 then local val = this:EPGPGetItemCostByID(item:GetItemId(),true) if val and item:IsEquippable() and wndTarget then wndTarget:SetText(val ~= "" and (val .. " GP") or "") wndTarget:SetTextColor("xkcdAmber") wndTarget:SetFont("Nameplates") wndTarget:SetTextFlags("DT_VCENTER", true) wndTarget:SetTextFlags("DT_CENTER", true) if wndTarget:GetName() == "SeparatorSmallLine" then wndTarget:SetSprite("CRB_Tooltips:sprTooltip_HorzDividerDiagonal") local l,t,r,b = wndTarget:GetAnchorOffsets() wndTarget:SetAnchorOffsets(l,t+3,r,b-1) end elseif val then local wndBox = Apollo.LoadForm("ui\\Tooltips\\TooltipsForms.xml", "ItemBasicStatsLine", wndTooltip:FindChild("ItemTooltip_BasicStatsBox")) if wndBox then wndBox:SetAML("<P Font=\"Nameplates\" TextColor=\"xkcdAmber\"> ".. val .. " GP".." </P>") wndBox:SetTextFlags("DT_RIGHT",true) wndBox:SetHeightToContentHeight() wndBox:SetAnchorOffsets(130,0,0,wndBox:GetHeight()) end end end if wndTooltipComp then wndTarget = wndTooltipComp:FindChild("SeparatorDiagonal") and wndTooltipComp:FindChild("SeparatorDiagonal") or wndTooltipComp:FindChild("SeparatorSmallLine") end if wndTooltipComp and wndTarget and tOpt.itemCompare and tOpt.itemCompare:IsEquippable() then local val = this:EPGPGetItemCostByID(tOpt.itemCompare:GetItemId(),true) wndTarget:SetText(val ~= "" and (val .. " GP") or "") wndTarget:SetTextColor("xkcdAmber") wndTarget:SetFont("Nameplates") wndTarget:SetTextFlags("DT_VCENTER", true) wndTarget:SetTextFlags("DT_CENTER", true) if wndTarget:GetName() == "SeparatorSmallLine" then wndTarget:SetSprite("CRB_Tooltips:sprTooltip_HorzDividerDiagonal") local l,t,r,b = wndTarget:GetAnchorOffsets() wndTarget:SetAnchorOffsets(l,t+3,r,b-1) end end if wndTooltip and string.find(item:GetName(),this.Locale["#Imprint"]) then -- gotta insert and arrange stuff --local wndBox = wndTooltip:FindChild("SimpleRowSmallML") local nGP = this:EPGPGetItemCostByID(item:GetItemId(),true) if nGP == "" then return end -- cause there are imprints that are not GA/DS ones ... drop 6 local wndBox = Apollo.LoadForm("ui\\Tooltips\\TooltipsForms.xml", "ItemBasicStatsLine", wndTooltip:FindChild("ItemTooltip_BasicStatsBox")) if wndBox then wndBox:SetAML("<P Font=\"Nameplates\" TextColor=\"xkcdAmber\"> ".. nGP .. " GP".." </P>") wndBox:SetTextFlags("DT_RIGHT",true) wndBox:SetHeightToContentHeight() wndBox:SetAnchorOffsets(130,0,0,wndBox:GetHeight()) end end return wndTooltip , wndTooltipComp end function printAllStuff(wnd) if #wnd:GetChildren() > 0 then for k , child in ipairs(wnd:GetChildren()) do Print(child:GetName() .. " " .. child:GetText() .. " parent: " .. wnd:GetName()) printAllStuff(child) end end end function DKP:AttachBelow(luaCaller,strText, wndHeader) local words = {} for word in string.gmatch(strText,"%S+") do table.insert(words,word) end -- Old but working --[[wndAML = Apollo.LoadForm(luaCaller.xmlDoc, "MLItemID", wndHeader, luaCaller) wndAML:SetAML(string.format("<T Font=\"CRB_InterfaceSmall\" TextColor=\"%s\">%s</T>",kUIBody, strText) .. "<T Font=\"Nameplates\" TextColor=\"xkcdAmber\">".. self:EPGPGetItemCostByID(tonumber(words[3])).." </T>") local nWidth, nHeight = wndAML:SetHeightToContentHeight() nHeight = nHeight + 1 wndAML:SetAnchorPoints(0,1,1,1) wndAML:SetAnchorOffsets(25, 3 - nHeight, 3, 0)]] -- From Update 1_31 wndAML = Apollo.LoadForm(luaCaller.xmlDoc, "MLItemID", wndHeader, luaCaller) wndAML:SetAML(string.format("<T Font=\"CRB_InterfaceSmall\" TextColor=\"%s\">%s</T>",kUIBody, strText) .. "<T Font=\"Nameplates\" TextColor=\"xkcdAmber\">".. self:EPGPGetItemCostByID(tonumber(words[3])).." </T>") local nWidth, nHeight = wndAML:SetHeightToContentHeight() local nLeft, nTop, nRight, nBottom = wndHeader:GetAnchorOffsets() --Set BGart to not strech to fit so we have extra space for the ItemID; not ideal local BGArt = wndHeader:FindChild("ItemTooltip_HeaderBG") local QBar = wndHeader:FindChild("ItemTooltip_HeaderBar") local nQLeft, nQTop, nQRight, nQBottom = QBar:GetAnchorOffsets() QBar:SetAnchorOffsets(nQLeft, nQTop - nItemIDSpacing, nQRight, nQBottom - nItemIDSpacing) -- move up with the rest BGArt:SetAnchorPoints(0,0,1,0) --set to no longer stretch to fit BGArt:SetAnchorOffsets(nLeft, nTop, nRight, nBottom) wndHeader:SetAnchorOffsets(nLeft, nTop, nRight, nBottom + nItemIDSpacing) -- add space luaCaller:ArrangeChildrenVertAndResize(wndHeader:GetParent()) --set itemID position wndAML:SetAnchorPoints(0,1,1,1) wndAML:SetAnchorOffsets(25, 2 - nHeight, 3, 0) end
gpl-2.0
TETOO2020/THETETOO_A8
plugins/aboasola.lua
6
1124
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY tetoo ▀▄ ▄▀ ▀▄ ▄▀ BY nmore (@l_l_lo) ▀▄ ▄▀ ▀▄ ▄▀ JUST WRITED BY l_l_ll ▀▄ ▄▀ ▀▄ ▄▀ broadcast : مـعرفي ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] do local function sadik(msg, matches) if ( msg.text ) then if ( msg.to.type == "user" ) then return "اذا كنت تريد التحدث مع المطورين اضعط ع احد المعرفات التالي \n 🎀 @ll15l - @l_l_lo \n او اذا محظور اضغط هنا \n 🎀 @k4k33_bot - @k4k33_bot \n 🎀قناة الـسـورس \n @NO_NO2\n " end end -- @l_l_lo end return { patterns = { "(.*)$" }, run = sadik, } end -- By @l_l_lo
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c66540884.lua
7
1243
--トリック・デーモン function c66540884.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(66540884,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetCode(EVENT_TO_GRAVE) e1:SetCountLimit(1,66540884) e1:SetCondition(c66540884.thcon) e1:SetTarget(c66540884.thtg) e1:SetOperation(c66540884.thop) c:RegisterEffect(e1) end function c66540884.thcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_EFFECT) or c:IsReason(REASON_BATTLE) end function c66540884.thfilter(c) return c:IsSetCard(0x45) and c:GetCode()~=66540884 and c:IsAbleToHand() end function c66540884.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c66540884.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c66540884.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c66540884.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end
gpl-2.0
ryoenji/libgdx
demos/pax-britannica/pax-britannica-android/assets/data/scripts/easy_enemy_production.lua
5
2312
local SCRIPTED_ACTIONS = { { 'fighter', 'fighter', 'fighter', 'fighter', 'bomber' }, { 'fighter', 'fighter', 'fighter', 'bomber' }, { 'fighter', 'fighter', 'bomber' }, { 'fighter', 'fighter', 'fighter', 'frigate' } } local action_index = 0 local frames_to_hold = 0 local accumulated_frames = 0 local frames_to_wait = 0 local script_index = 0 self.resources.harvest_rate = self.resources.harvest_rate * 0.8 local function next_script() script_index = math.ceil(math.random() * table.getn(SCRIPTED_ACTIONS)) --print ('player ' .. self.ship.player .. ' picked script #' .. script_index) end local function next_action() accumulated_frames = 0 action_index = action_index + 1 if action_index > table.getn(SCRIPTED_ACTIONS[script_index]) then action_index = 1 next_script() end -- how much time to hold the button frames_to_hold = (self.production.UNIT_COSTS[SCRIPTED_ACTIONS[script_index][action_index]] - self.production.UNIT_COSTS['fighter']) / self.production.BUILDING_SPEED + 2 + math.random() * 60 -- how much time to wait before actually performing the scripted action? if not self.resources then return end local missing_resources = (self.production.UNIT_COSTS[SCRIPTED_ACTIONS[script_index][action_index]] - self.resources.amount) / self.resources.harvest_rate frames_to_wait = math.max(missing_resources + 1, 0) + math.random() * 60 --print('producing ' .. SCRIPTED_ACTIONS[action_index] .. ' : ' .. frames_to_hold .. ' held, ' .. frames_to_wait .. ' waited') end -- take the first action on init next_script() next_action() function update() -- make sure we still have enemies local found_enemy = false for _, actor in ipairs(game.actors.get('factory')) do if actor.ship and actor.ship.player ~= self.ship.player then found_enemy = true end end if not found_enemy then self.production.button_held = false return end accumulated_frames = accumulated_frames + 1 self.production.button_held = accumulated_frames > frames_to_wait and accumulated_frames < frames_to_hold + frames_to_wait if accumulated_frames > frames_to_hold + frames_to_wait then next_action() end end
apache-2.0
Hooodini/HooECS
spec/engine_system_spec.lua
1
10763
package.path = package.path .. ";./?.lua;./?/init.lua;./init.lua" local HooECS = require('HooECS') HooECS.initialize({ globals = true }) describe('Engine', function() local UpdateSystem, DrawSystem, MultiSystem, Component1, Component2 local entity, entity2, entity3 local testSystem, engine setup(function() -- Creates a Update System UpdateSystem = HooECS.class('UpdateSystem', System) function UpdateSystem:initialize() System.initialize(self) self.entitiesAdded = 0 self.entitiesRemoved = 0 end function UpdateSystem:requires() return {'Component1'} end function UpdateSystem:update() for _, entity in pairs(self.targets) do entity:get('Component1').number = entity:get('Component1').number + 5 end end function UpdateSystem:onAddEntity() self.entitiesAdded = self.entitiesAdded + 1 end function UpdateSystem:onRemoveEntity() self.entitiesRemoved = self.entitiesRemoved + 1 end -- Creates a Draw System DrawSystem = HooECS.class('DrawSystem', System) function DrawSystem:requires() return {'Component1'} end function DrawSystem:draw() for _, entity in pairs(self.targets) do entity:get('Component1').number = entity:get('Component1').number + 10 end end -- Creates a system with update and draw function BothSystem = HooECS.class('BothSystem', System) function BothSystem:requires() return {'Component1', 'Component2'} end function BothSystem:update() for _, entity in pairs(self.targets) do entity:get('Component1').number = entity:get('Component1').number + 5 end end function BothSystem:draw() end -- Creates a System with multiple requirements MultiSystem = HooECS.class('MultiSystem', System) function MultiSystem:requires() return {name1 = {'Component1'}, name2 = {'Component2'}} end Component1 = Component.create('Component1') Component1.number = 1 Component2 = Component.create('Component2') Component2.number = 2 end) before_each(function() entity = Entity() entity2 = Entity() entity3 = Entity() updateSystem = UpdateSystem() drawSystem = DrawSystem() bothSystem = BothSystem() multiSystem2 = MultiSystem() engine = Engine() end) it(':addSystem() adds update Systems', function() engine:addSystem(updateSystem) assert.are.equal(engine.systems['update'][1], updateSystem) end) it(':addSystem() adds System to systemRegistry', function() engine:addSystem(updateSystem) assert.are.equal(engine.systemRegistry[updateSystem.class.name], updateSystem) end) it(':addSystem() doesn`t add same system type twice', function() engine:addSystem(updateSystem) local newUpdateSystem = UpdateSystem() engine:addSystem(newUpdateSystem) assert.are.equal(engine.systems['update'][1], updateSystem) assert.are.equal(engine.systemRegistry[updateSystem.class.name], updateSystem) end) it(':addSystem() adds draw Systems', function() engine:addSystem(drawSystem) assert.are.equal(engine.systems['draw'][1], drawSystem) end) it(':addSystem() doesn`t add Systems with both, but does, if specified with type', function() engine:addSystem(bothSystem) assert.are_not.equal(engine.systems['draw'][1], bothSystem) assert.are_not.equal(engine.systems['update'][1], bothSystem) engine:addSystem(bothSystem, 'draw') engine:addSystem(bothSystem, 'update') assert.are.equal(engine.systems['draw'][1], bothSystem) assert.are.equal(engine.systems['update'][1], bothSystem) end) it(':addSystem() adds BothSystem to singleRequirements, if specified with type', function() engine:addSystem(bothSystem) assert.are_not.equal(type(engine.singleRequirements['Component1']), 'table') assert.are_not.equal(type(engine.singleRequirements['Component2']), 'table') engine:addSystem(bothSystem, 'draw') assert.are.equal(engine.singleRequirements['Component1'][1], bothSystem) assert.are_not.equal(type(engine.singleRequirements['Component2']), 'table') end) it(':addSystem() adds BothSystem to singleRequirements, if specified with type', function() engine:addSystem(bothSystem) assert.are_not.equal(type(engine.allRequirements['Component1']), 'table') assert.are_not.equal(type(engine.allRequirements['Component2']), 'table') engine:addSystem(bothSystem, 'draw') assert.are.equal(engine.allRequirements['Component1'][1], bothSystem) assert.are.equal(engine.allRequirements['Component2'][1], bothSystem) end) it(':addSystem() doesn`t add Systems to requirement lists multiple times', function() engine:addSystem(bothSystem, 'draw') engine:addSystem(bothSystem, 'update') assert.are.equal(engine.singleRequirements['Component1'][1], bothSystem) assert.are_not.equal(engine.singleRequirements['Component1'][2], bothSystem) assert.are_not.equal(type(engine.singleRequirements['Component2']), 'table') assert.are.equal(engine.allRequirements['Component1'][1], bothSystem) assert.are.equal(engine.allRequirements['Component2'][1], bothSystem) assert.are_not.equal(engine.allRequirements['Component1'][2], bothSystem) assert.are_not.equal(engine.allRequirements['Component2'][2], bothSystem) end) it(':addSystem() doesn`t add Systems to system lists multiple times', function() engine:addSystem(bothSystem, 'draw') engine:addSystem(bothSystem, 'draw') engine:addSystem(bothSystem, 'update') engine:addSystem(bothSystem, 'update') assert.are.equal(engine.systems['draw'][1], bothSystem) assert.are.equal(engine.systems['update'][1], bothSystem) assert.are_not.equal(engine.systems['draw'][2], bothSystem) assert.are_not.equal(engine.systems['update'][2], bothSystem) end) it(':update() updates Systems', function() entity:add(Component1()) engine:addEntity(entity) engine:addSystem(updateSystem) assert.are.equal(entity:get('Component1').number, 1) engine:update() assert.are.equal(entity:get('Component1').number, 6) end) it(':update() updates Systems', function() entity:add(Component1()) engine:addEntity(entity) engine:addSystem(drawSystem) assert.are.equal(entity:get('Component1').number, 1) engine:draw() assert.are.equal(entity:get('Component1').number, 11) end) it(':update() updates Systems', function() entity:add(Component1()) engine:addEntity(entity) engine:addSystem(drawSystem) assert.are.equal(entity:get('Component1').number, 1) engine:draw() assert.are.equal(entity:get('Component1').number, 11) end) it(':stop(), start(), toggle() works', function() entity:add(Component1()) engine:addEntity(entity) engine:addSystem(drawSystem) assert.are.equal(entity:get('Component1').number, 1) engine:draw() assert.are.equal(entity:get('Component1').number, 11) engine:stopSystem('DrawSystem') engine:draw() assert.are.equal(entity:get('Component1').number, 11) engine:startSystem('DrawSystem') engine:draw() assert.are.equal(entity:get('Component1').number, 21) engine:toggleSystem('DrawSystem') engine:draw() assert.are.equal(entity:get('Component1').number, 21) engine:toggleSystem('DrawSystem') engine:draw() assert.are.equal(entity:get('Component1').number, 31) end) it('Calling system status functions on not existing systems throws debug message.', function() -- Mock HooECS debug function local debug_spy = spy.on(HooECS, 'debug') engine:startSystem('weirdstufflol') -- Assert that the debug function has been called -- and clear spy call history assert.spy(debug_spy).was_called() HooECS.debug:clear() engine:toggleSystem('weirdstufflol') assert.spy(debug_spy).was_called() HooECS.debug:clear() engine:stopSystem('weirdstufflol') assert.spy(debug_spy).was_called() HooECS.debug:clear() HooECS.debug:revert() end) it('calls UpdateSystem:onComponentAdded when a component is added to UpdateSystem', function() assert.are.equal(updateSystem.entitiesAdded, 0) entity:add(Component1()) engine:addSystem(updateSystem) engine:addEntity(entity) assert.are.equal(updateSystem.entitiesAdded, 1) end) it(':addSystem(system, "derp") fails', function() local debug_spy = spy.on(HooECS, 'debug') engine:addSystem(drawSystem, 'derp') assert.is_nil(engine.systemRegistry['DrawSystem']) assert.spy(debug_spy).was_called() HooECS.debug:revert() end) it('refuses to add two instances of the same system', function() local debug_spy = spy.on(HooECS, 'debug') engine:addSystem(DrawSystem()) engine:addSystem(DrawSystem()) assert.spy(debug_spy).was_called() HooECS.debug:clear() engine:addSystem(BothSystem(), 'update') engine:addSystem(BothSystem(), 'draw') assert.spy(debug_spy).was_called() HooECS.debug:revert() end) it('Entity:activate() & Entity:deactivate() works', function() local count = function(t) local c = 0 for _, v in pairs(t) do c = c + 1 end return c end entity:add(Component1()) engine:addSystem(updateSystem) engine:addEntity(entity) assert.are.equal(count(updateSystem.targets), 1) assert.are.equal(entity.active, true) entity:deactivate() assert.are.equal(count(updateSystem.targets), 0) assert.are.equal(entity.active, false) entity:activate() assert.are.equal(count(updateSystem.targets), 1) assert.are.equal(entity.active, true) end) it('Entity:getEngine() returns engine registered to', function() engine:addEntity(entity) assert.are.equal(entity:getEngine(), engine) end) end)
mit
anshkumar/yugioh-glaze
assets/script/c68191243.lua
6
1508
--黒蠍団召集 function c68191243.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCondition(c68191243.con) e1:SetTarget(c68191243.tg) e1:SetOperation(c68191243.op) c:RegisterEffect(e1) end function c68191243.cfilter(c) return c:IsFaceup() and c:IsCode(76922029) end function c68191243.con(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(c68191243.cfilter,tp,LOCATION_ONFIELD,0,1,nil) end function c68191243.filter(c,e,tp) return c:IsSetCard(0x1a) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c68191243.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c68191243.filter,tp,LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function c68191243.op(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return end local g=Duel.GetMatchingGroup(c68191243.filter,tp,LOCATION_HAND,0,nil,e,tp) while g:GetCount()>0 and ft>0 do Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,1,1,nil) Duel.SpecialSummonStep(sg:GetFirst(),0,tp,tp,false,false,POS_FACEUP) ft=ft-1 g:Remove(Card.IsCode,nil,sg:GetFirst():GetCode()) if g:GetCount()>0 and ft>0 and not Duel.SelectYesNo(tp,aux.Stringid(68191243,0)) then ft=0 end end Duel.SpecialSummonComplete() end
gpl-2.0
Mordonus/RaidOps
MasterLootDependency/MasterLootDependency.lua
2
31109
----------------------------------------------------------------------------------------------- -- Client Lua Script for Masterloot -- Copyright (c) NCsoft. All rights reserved ----------------------------------------------------------------------------------------------- --dsfdsfsd require "Window" require "Apollo" require "GroupLib" require "Item" require "GameLib" local MasterLoot = {} local ktClassToIcon = { [GameLib.CodeEnumClass.Medic] = "Icon_Windows_UI_CRB_Medic", [GameLib.CodeEnumClass.Esper] = "Icon_Windows_UI_CRB_Esper", [GameLib.CodeEnumClass.Warrior] = "Icon_Windows_UI_CRB_Warrior", [GameLib.CodeEnumClass.Stalker] = "Icon_Windows_UI_CRB_Stalker", [GameLib.CodeEnumClass.Engineer] = "Icon_Windows_UI_CRB_Engineer", [GameLib.CodeEnumClass.Spellslinger] = "Icon_Windows_UI_CRB_Spellslinger", } local ktClassToString = { [GameLib.CodeEnumClass.Medic] = "Medic", [GameLib.CodeEnumClass.Esper] = "Esper", [GameLib.CodeEnumClass.Warrior] = "Warrior", [GameLib.CodeEnumClass.Stalker] = "Stalker", [GameLib.CodeEnumClass.Engineer] = "Engineer", [GameLib.CodeEnumClass.Spellslinger] = "Spellslinger", } function MasterLoot:new(o) o = o or {} setmetatable(o, self) self.__index = self return o end function MasterLoot:Init() if Apollo.GetAddon("RaidOpsLootHex") then return end Apollo.RegisterAddon(self) end function MasterLoot:OnLoad() self.xmlDoc = XmlDoc.CreateFromFile("MasterLootDependency.xml") self.xmlDoc:RegisterCallback("OnDocumentReady", self) end function MasterLoot:OnDocumentReady() if self.xmlDoc == nil then return end self:MLLightInit() Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self) Apollo.RegisterEventHandler("MasterLootUpdate", "OnMasterLootUpdate", self) Apollo.RegisterEventHandler("LootAssigned", "OnLootAssigned", self) Apollo.RegisterEventHandler("Group_Updated", "OnGroupUpdated", self) Apollo.RegisterEventHandler("Group_Left", "OnGroup_Left", self) -- When you leave the group Apollo.RegisterEventHandler("GenericEvent_ToggleGroupBag", "OnToggleGroupBag", self) -- Master Looter Window self.wndMasterLoot = Apollo.LoadForm(self.xmlDoc, "MasterLootWindow", nil, self) self.wndMasterLoot:SetSizingMinimum(550, 310) if self.locSavedMasterWindowLoc then self.wndMasterLoot:MoveToLocation(self.locSavedMasterWindowLoc) end self.wndMasterLoot_ItemList = self.wndMasterLoot:FindChild("ItemList") self.wndMasterLoot_LooterList = self.wndMasterLoot:FindChild("LooterList") self.wndMasterLoot:Show(false) -- Looter Window self.wndLooter = Apollo.LoadForm(self.xmlDoc, "LooterWindow", nil, self) if self.locSavedLooterWindowLoc then self.wndLooter:MoveToLocation(self.locSavedLooterWindowLoc) end self.wndLooter_ItemList = self.wndLooter:FindChild("ItemList") self.wndLooter:Show(false) self.tOld_MasterLootList = {} -- Master Looter Global Vars self.tMasterLootSelectedItem = nil self.tMasterLootSelectedLooter = nil end function MasterLoot:OnWindowManagementReady() Event_FireGenericEvent("WindowManagementAdd", { wnd = self.wndMasterLoot, strName = Apollo.GetString("Group_MasterLoot"), nSaveVersion = 1 }) end function MasterLoot:OnToggleGroupBag() self:OnMasterLootUpdate(true,true) -- true makes it force open if we have items , 2nd true is to idicate demand end ---------------------------- function MasterLoot:OnMasterLootUpdate(bForceOpen,bDemand) if Apollo.GetAddon("RaidOps") and not self.wndMasterLoot:IsShown() then if Apollo.GetAddon("RaidOps").tItems["settings"]["ML"].bAppOnDemand and not bDemand then return end end if self.settings.bLightMode then self:MLLPopulateItems() return end local tMasterLoot = GameLib.GetMasterLoot() local tMasterLootItemList = {} local tLooterItemList = {} local bWeHaveLoot = false local bWeHaveNewLoot = false local bLootWasRemoved = false local bLootersChanged = false -- Go through NEW items for idxNewItem, tCurNewItem in pairs(tMasterLoot) do bWeHaveLoot = true -- Break items out into MasterLooter and Looter lists (which UI displays them) if tCurNewItem.bIsMaster then table.insert(tMasterLootItemList, tCurNewItem) else table.insert(tLooterItemList, tCurNewItem) end -- Search through last MasterLootList to see if we got NEW items local bFoundItem = false for idxOldItem, tCurOldItem in pairs (self.tOld_MasterLootList) do if tCurNewItem.nLootId == tCurOldItem.nLootId then -- persistant item bFoundItem = true local bNewLooter = false local bLostLooter = false for idxNewLooter, unitNewLooter in pairs (tCurNewItem.tLooters) do local bFoundLooter = false for idxOldLooter, unitOldLooter in pairs (tCurOldItem.tLooters) do if unitNewLooter == unitOldLooter then bFoundLooter = true break end end if not bFoundLooter then bNewLooter = true break end end if not bNewLooter then for idxOldLooter, unitOldLooter in pairs (tCurOldItem.tLooters) do local bFoundLooter = false for idxNewLooter, unitNewLooter in pairs (tCurNewItem.tLooters) do if unitOldLooter == unitNewLooter then bFoundLooter = true break end end if not bFoundLooter then bLostLooter = true break end end end if bNewLooter or bLostLooter then bLootersChanged = true break end end end if not bFoundItem then bWeHaveNewLoot = true end end -- Go through OLD items for idxOldItem, tCurOldItem in pairs (self.tOld_MasterLootList) do -- Search through new list to see if we LOST any items local bFound = false for idxNewItem, tCurNewItem in pairs(tMasterLoot) do if tCurNewItem.nLootId == tCurOldItem.nLootId then -- persistant item bFound = true break end end if not bFound then bLootWasRemoved = true break end end self.tOld_MasterLootList = tMasterLoot if bForceOpen == true and bWeHaveLoot then -- pop window if closed, update open windows if next(tMasterLootItemList) then self.wndMasterLoot:Show(true) self:RefreshMasterLootItemList(tMasterLootItemList) self:RefreshMasterLootLooterList(tMasterLootItemList) end if next(tLooterItemList) then self.wndLooter:Show(true) self:RefreshLooterItemList(tLooterItemList) end elseif bWeHaveLoot then if bWeHaveNewLoot then -- pop window if closed, update open windows if next(tMasterLootItemList) then self.wndMasterLoot:Show(true) self:RefreshMasterLootItemList(tMasterLootItemList) self:RefreshMasterLootLooterList(tMasterLootItemList) end if next(tLooterItemList) then self.wndLooter:Show(true) self:RefreshLooterItemList(tLooterItemList) end elseif bLootWasRemoved or bLootersChanged then -- update open windows if self.wndMasterLoot:IsShown() and next(tMasterLootItemList) then self:RefreshMasterLootItemList(tMasterLootItemList) self:RefreshMasterLootLooterList(tMasterLootItemList) end if self.wndLooter:IsShown() and next(tLooterItemList) then self:RefreshLooterItemList(tLooterItemList) end end else -- close any open windows if self.wndMasterLoot:IsShown() then self.locSavedMasterWindowLoc = self.wndMasterLoot:GetLocation() self.tMasterLootSelectedItem = nil self.tMasterLootSelectedLooter = nil self.wndMasterLoot_ItemList:DestroyChildren() self.wndMasterLoot_LooterList:DestroyChildren() self.wndMasterLoot:Show(false) end if self.wndLooter:IsShown() then self.locSavedLooterWindowLoc = self.wndLooter:GetLocation() self.wndLooter_ItemList:DestroyChildren() self.wndLooter:Show(false) end end if self.tMasterLootSelectedItem ~= nil and self.tMasterLootSelectedLooter ~= nil then self.wndMasterLoot:FindChild("Assignment"):Enable(true) else self.wndMasterLoot:FindChild("Assignment"):Enable(false) end end function MasterLoot:RefreshMasterLootItemList(tMasterLootItemList) self.wndMasterLoot_ItemList:DestroyChildren() for idx, tItem in ipairs (tMasterLootItemList) do local wndCurrentItem = Apollo.LoadForm(self.xmlDoc, "ItemButton", self.wndMasterLoot_ItemList, self) wndCurrentItem:FindChild("ItemIcon"):SetSprite(tItem.itemDrop:GetIcon()) wndCurrentItem:FindChild("ItemName"):SetText(tItem.itemDrop:GetName()) wndCurrentItem:SetData(tItem) if self.tMasterLootSelectedItem ~= nil and (self.tMasterLootSelectedItem.nLootId == tItem.nLootId) then wndCurrentItem:SetCheck(true) self:RefreshMasterLootLooterList(tMasterLootItemList) end --Tooltip.GetItemTooltipForm(self, wndCurrentItem , tItem.itemDrop, {bPrimary = true, bSelling = false, itemCompare = tItem.itemDrop:GetEquippedItemForItemType()}) end self.wndMasterLoot_ItemList:ArrangeChildrenVert(0) end function MasterLoot:RefreshMasterLootLooterList(tMasterLootItemList) self.wndMasterLoot_LooterList:DestroyChildren() if self.tMasterLootSelectedItem ~= nil then for idx, tItem in pairs (tMasterLootItemList) do if tItem.nLootId == self.tMasterLootSelectedItem.nLootId then local bStillHaveLooter = false for idx, unitLooter in pairs(tItem.tLooters) do local wndCurrentLooter = Apollo.LoadForm(self.xmlDoc, "CharacterButton", self.wndMasterLoot_LooterList, self) wndCurrentLooter:FindChild("CharacterName"):SetText(unitLooter:GetName()) wndCurrentLooter:FindChild("CharacterLevel"):SetText(unitLooter:GetBasicStats().nLevel) wndCurrentLooter:FindChild("ClassIcon"):SetSprite(ktClassToIcon[unitLooter:GetClassId()]) wndCurrentLooter:SetData(unitLooter) if self.tMasterLootSelectedLooter == unitLooter then wndCurrentLooter:SetCheck(true) bStillHaveLooter = true end end if not bStillHaveLooter then self.tMasterLootSelectedLooter = nil end -- get out of range people -- tLootersOutOfRange if tItem.tLootersOutOfRange and next(tItem.tLootersOutOfRange) then for idx, strLooterOOR in pairs(tItem.tLootersOutOfRange) do local wndCurrentLooter = Apollo.LoadForm(self.xmlDoc, "CharacterButton", self.wndMasterLoot_LooterList, self) wndCurrentLooter:FindChild("CharacterName"):SetText(String_GetWeaselString(Apollo.GetString("Group_OutOfRange"), strLooterOOR)) wndCurrentLooter:FindChild("ClassIcon"):SetSprite("CRB_GroupFrame:sprGroup_Disconnected") wndCurrentLooter:Enable(false) end end self.wndMasterLoot_LooterList:ArrangeChildrenVert(0, function(a,b) return a:FindChild("CharacterName"):GetText() < b:FindChild("CharacterName"):GetText() end) end end end end function MasterLoot:RefreshLooterItemList(tLooterItemList) self.wndLooter_ItemList:DestroyChildren() for idx, tItem in pairs (tLooterItemList) do local wndCurrentItem = Apollo.LoadForm(self.xmlDoc, "LooterItemButton", self.wndLooter_ItemList, self) wndCurrentItem:FindChild("ItemIcon"):SetSprite(tItem.itemDrop:GetIcon()) wndCurrentItem:FindChild("ItemName"):SetText(tItem.itemDrop:GetName()) wndCurrentItem:SetData(tItem) Tooltip.GetItemTooltipForm(self, wndCurrentItem , tItem.itemDrop, {bPrimary = true, bSelling = false, itemCompare = tItem.itemDrop:GetEquippedItemForItemType()}) end self.wndLooter_ItemList:ArrangeChildrenVert(0) end ---------------------------- function MasterLoot:OnGroupUpdated() if GroupLib.AmILeader() then if self.wndLooter:IsShown() then self:OnCloseLooterWindow() self:OnMasterLootUpdate(true) end else if self.wndMasterLoot:IsShown() then self:OnCloseMasterWindow() self:OnMasterLootUpdate(true) end end end function MasterLoot:OnGroup_Left() if self.wndMasterLoot:IsShown() then self:OnCloseMasterWindow() --self:OnMasterLootUpdate(true) end end ---------------------------- function MasterLoot:OnItemMouseButtonUp(wndHandler, wndControl, eMouseButton) -- Both LooterItemButton and ItemButton if eMouseButton == GameLib.CodeEnumInputMouse.Right then local tItemInfo = wndHandler:GetData() if tItemInfo and tItemInfo.itemDrop then Event_FireGenericEvent("GenericEvent_ContextMenuItem", tItemInfo.itemDrop) end end end function MasterLoot:OnItemCheck(wndHandler, wndControl, eMouseButton) if eMouseButton ~= GameLib.CodeEnumInputMouse.Right then local tItemInfo = wndHandler:GetData() if tItemInfo and tItemInfo.bIsMaster then self.tMasterLootSelectedItem = tItemInfo self.tMasterLootSelectedLooter = nil self:OnMasterLootUpdate(true) end end end function MasterLoot:OnItemUncheck(wndHandler, wndControl, eMouseButton) if eMouseButton ~= GameLib.CodeEnumInputMouse.Right then self.tMasterLootSelectedItem = nil self.tMasterLootSelectedLooter = nil self:OnMasterLootUpdate(true) end end ---------------------------- function MasterLoot:OnCharacterMouseButtonUp(wndHandler, wndControl, eMouseButton) if eMouseButton == GameLib.CodeEnumInputMouse.Right then local unitPlayer = wndControl:GetData() -- Potentially nil local strPlayer = wndHandler:FindChild("CharacterName"):GetText() if unitPlayer then Event_FireGenericEvent("GenericEvent_NewContextMenuPlayerDetailed", wndHandler, strPlayer, unitPlayer) else Event_FireGenericEvent("GenericEvent_NewContextMenuPlayer", wndHandler, strPlayer) end end end function MasterLoot:OnCharacterCheck(wndHandler, wndControl, eMouseButton) if eMouseButton ~= GameLib.CodeEnumInputMouse.Right then if type(wndControl:GetData()) == "table" then -- if it's guild bank entry it is table as a flag self.tMasterLootSelectedLooter = wndControl:GetData().unit self.bSelectedGuildBank = true else self.tMasterLootSelectedLooter = wndControl:GetData() self.bSelectedGuildBank = false end if self.tMasterLootSelectedItem ~= nil then self.wndMasterLoot:FindChild("Assignment"):Enable(true) else self.wndMasterLoot:FindChild("Assignment"):Enable(false) end end end ---------------------------- function MasterLoot:OnCharacterUncheck(wndHandler, wndControl, eMouseButton) if eMouseButton ~= GameLib.CodeEnumInputMouse.Right then self.tMasterLootSelectedLooter = nil self.wndMasterLoot:FindChild("Assignment"):Enable(false) end end ---------------------------- function MasterLoot:OnAssignDown(wndHandler, wndControl, eMouseButton) if self.tMasterLootSelectedItem ~= nil and self.tMasterLootSelectedLooter ~= nil then -- gotta save before it gets wiped out by event local SelectedLooter = self.tMasterLootSelectedLooter local SelectedItemLootId = self.tMasterLootSelectedItem.nLootId self.tMasterLootSelectedLooter = nil self.tMasterLootSelectedItem = nil GameLib.AssignMasterLoot(SelectedItemLootId , SelectedLooter) end end ---------------------------- function MasterLoot:OnCloseMasterWindow() self.locSavedMasterWindowLoc = self.wndMasterLoot:GetLocation() self.wndMasterLoot_ItemList:DestroyChildren() self.wndMasterLoot_LooterList:DestroyChildren() self.tMasterLootSelectedItem = nil self.tMasterLootSelectedLooter = nil self.wndMasterLoot:Show(false) end ------------------------------------ function MasterLoot:OnCloseLooterWindow() self.locSavedLooterWindowLoc = self.wndLooter:GetLocation() self.wndLooter_ItemList:DestroyChildren() self.wndLooter:Show(false) end ---------------------------- function MasterLoot:OnLootAssigned(tLootInfo) Event_FireGenericEvent("GenericEvent_LootChannelMessage", String_GetWeaselString(Apollo.GetString("CRB_MasterLoot_AssignMsg"), tLootInfo.itemLoot:GetName(), tLootInfo.strPlayer)) end local knSaveVersion = 1 function MasterLoot:OnSave(eType) if eType ~= GameLib.CodeEnumAddonSaveLevel.Account then return end local locWindowMasterLoot = self.wndMasterLoot and self.wndMasterLoot:GetLocation() or self.locSavedMasterWindowLoc local locWindowLooter = self.wndLooter and self.wndLooter:GetLocation() or self.locSavedLooterWindowLoc local tSave = { tWindowMasterLocation = locWindowMasterLoot and locWindowMasterLoot:ToTable() or nil, tWindowLooterLocation = locWindowLooter and locWindowLooter:ToTable() or nil, nSaveVersion = knSaveVersion, } tSave.settings = self.settings return tSave end function MasterLoot:OnRestore(eType, tSavedData) if tSavedData and tSavedData.nSaveVersion == knSaveVersion then if tSavedData.tWindowMasterLocation then self.locSavedMasterWindowLoc = WindowLocation.new(tSavedData.tWindowMasterLocation) end if tSavedData.tWindowLooterLocation then self.locSavedLooterWindowLoc = WindowLocation.new(tSavedData.tWindowLooterLocation ) end local bShowWindow = #GameLib.GetMasterLoot() > 0 if self.wndGroupBag and bShowWindow then self.wndGroupBag:Show(bShowWindow) self:RedrawMasterLootWindow() end self.settings = tSavedData.settings end end local MasterLoot_Singleton = MasterLoot:new() MasterLoot_Singleton:Init() -- Master Loot light local ktQualColors = { [1] = "ItemQuality_Inferior", [2] = "ItemQuality_Average", [3] = "ItemQuality_Good", [4] = "ItemQuality_Excellent", [5] = "ItemQuality_Superb", [6] = "ItemQuality_Legendary", [7] = "ItemQuality_Artifact", } local ktKeys = { [81] = "Q", [87] = "W", [69] = "E", [82] = "R", [84] = "T", [89] = "Y", [85] = "U", [73] = "I", [79] = "O", [80] = "P", [65] = "A", [83] = "S", [68] = "D", [70] = "F", [71] = "G", [72] = "H", [74] = "J", [75] = "K", [76] = "L", [90] = "Z", [88] = "X", [67] = "C", [86] = "V", [66] = "B", [78] = "N", [77] = "M", } local function getDummyML(nCount) tDummy = {} while nCount ~= 0 do local id = math.random(1,60000) local item = Item.GetDataFromId(id) if item then table.insert(tDummy,{nLootId = math.random(1,100000),itemDrop = item,tLooters = {[math.random(100)] = GameLib.GetPlayerUnit()}}) nCount = nCount - 1 end end return tDummy end local tResizes = {} local bResizeRunning = false function MasterLoot:gracefullyResize(wnd,tTargets,bQuick,bQueue) if not bQueue then for k , resize in ipairs(tResizes) do if resize.wnd:GetName() == wnd:GetName() then table.remove(tResizes,k) end end end if bQuick then if tTargets.l then if tTargets.l - math.floor(tTargets.l/2)*2 ~= 0 then tTargets.l = tTargets.l - 1 end end if tTargets.t then if tTargets.t - math.floor(tTargets.t/2)*2 ~= 0 then tTargets.t = tTargets.t - 1 end end if tTargets.r then if tTargets.r - math.floor(tTargets.r/2)*2 ~= 0 then tTargets.r = tTargets.r + 1 end end if tTargets.b then if tTargets.b - math.floor(tTargets.b/2)*2 ~= 0 then tTargets.b = tTargets.b + 1 end end end table.insert(tResizes,{wnd = wnd,tTargets = tTargets,bQuick = bQuick}) if not bResizeRunning then Apollo.RegisterTimerHandler(.002,"GracefulResize",self) self.resizeTimer = ApolloTimer.Create(.002,true,"GracefulResize",self) bResizeRunning = true end end function MasterLoot:MLLClose() self.wndMLL:Show(false,false) end function MasterLoot:GracefulResize() local tCompleted = {} -- prevent duplicates for k , resize in ipairs(tResizes) do if not tCompleted[resize.wnd:GetName()] then tCompleted[resize.wnd:GetName()] = true local l,t,r,b = resize.wnd:GetAnchorOffsets() local nSpeed = resize.bQuick and 2 or 1 if resize.tTargets.l then if l > resize.tTargets.l then l = l-nSpeed elseif l < resize.tTargets.l then l = l+nSpeed end end if resize.tTargets.t then if t > resize.tTargets.t then t = t-nSpeed elseif t < resize.tTargets.t then t = t+nSpeed end end if resize.tTargets.r then if r > resize.tTargets.r then r = r-nSpeed elseif r < resize.tTargets.r then r = r+nSpeed end end if resize.tTargets.b then if b > resize.tTargets.b then b = b-nSpeed elseif b < resize.tTargets.b then b = b+nSpeed end end resize.wnd:SetAnchorOffsets(l,t,r,b) if l == (resize.tTargets.l or l) and r == (resize.tTargets.r or r) and b == (resize.tTargets.b or b) and t == (resize.tTargets.t or t) then table.remove(tResizes,k) end end end if #tResizes == 0 then bResizeRunning = false self.resizeTimer:Stop() end end local nTargetHeight function MasterLoot:MLLightInit() self.wndMLL = Apollo.LoadForm(self.xmlDoc,"MasterLootLight",nil,self) self.wndMLL:Show(false) Apollo.RegisterEventHandler("SystemKeyDown", "MLLKeyDown", self) if not self.settings then self.settings = {} end if self.settings.bLightMode == nil then self.settings.bLightMode = false end --self.MLDummy = getDummyML(10) nTargetHeight = self.wndMLL:GetHeight()+40 self:MLLPopulateItems() end local ktSlotOrder = { [16] = 1, [15] = 2, [2] = 3, [3] = 4, [0] = 5, [5] = 6, [1] = 7, [7] = 8, [11] = 9, [10] = 10, [4] = 11, [8] = 12 } local function sort_loot_slot( c,d ) local s1 = c.itemDrop:GetSlot() local s2 = d.itemDrop:GetSlot() return s1 == s2 and c.itemDrop:GetName() < d.itemDrop:GetName() or ktSlotOrder[s1] < ktSlotOrder[s2] end local function sort_loot(tML) local tReturn = {} local tRandomJunk = {} local tItems = {} for k , item in ipairs(tML) do if item.itemDrop:IsEquippable() then table.insert(tItems,item) else table.insert(tRandomJunk,item) end end table.sort(tRandomJunk,function (a,b) return a.itemDrop:GetName() < b.itemDrop:GetName() end) tReturn = tRandomJunk table.sort(tItems,function(a,b) local q1 = a.itemDrop:GetItemQuality() local q2 = b.itemDrop:GetItemQuality() return q1 == q2 and sort_loot_slot(a,b) or q1 > q2 end) for k , item in ipairs(tItems) do table.insert(tReturn,item) end return tReturn end local bItemSelected = false function MasterLoot:MLLPopulateItems(bResize) if #GameLib.GetMasterLoot() > 0 and self.settings.bLightMode then self.wndMLL:Show(true,false) end local bMaster = false if bItemSelected then return end self.wndMLL:FindChild("Items"):DestroyChildren() local tML = sort_loot(GameLib:GetMasterLoot()) for k , lootEntry in ipairs(tML) do if lootEntry.bIsMaster then bMaster = true break end end if not bMaster then return end for k , lootEntry in ipairs(tML) do local wnd = Apollo.LoadForm(self.xmlDoc,"LightItem",self.wndMLL:FindChild("Items"),self) wnd:FindChild("Qual"):SetBGColor(ktQualColors[lootEntry.itemDrop:GetItemQuality()]) wnd:FindChild("ItemName"):SetText(lootEntry.itemDrop:GetName()) wnd:FindChild("ItemIcon"):SetSprite(lootEntry.itemDrop:GetIcon()) Tooltip.GetItemTooltipForm(self,wnd,lootEntry.itemDrop,{bPrimary = true}) wnd:SetData(lootEntry) end if Apollo.GetAddon("RaidOps") then Apollo.GetAddon("RaidOps"):BQUpdateCounters() end self.wndMLL:FindChild("Items"):ArrangeChildrenVert() if bResize then self:gracefullyResize(self.wndMLL:FindChild("ItemsFrame"),{b=self.wndMLL:GetHeight()-100}) local l,t,r,b = self.wndMLL:FindChild("RecipientsFrame"):GetAnchorOffsets() self:gracefullyResize(self.wndMLL:FindChild("RecipientsFrame"),{t=b}) end end function MasterLoot:MLLSelectItem(wndHandler,wndControl) bItemSelected = true for k , child in ipairs(self.wndMLL:FindChild("Items"):GetChildren()) do if child ~= wndControl then child:Show(false) end end self:gracefullyResize(wndControl,{t=3,b=wndControl:GetHeight()+3},true) self:gracefullyResize(self.wndMLL:FindChild("ItemsFrame"),{b=190}) self:gracefullyResize(self.wndMLL:FindChild("RecipientsFrame"),{t=200}) self:MLLPopulateRecipients(wndControl:GetData()) self.nSelectedItem = wndControl:GetData().nLootId end function MasterLoot:MLLDeselectItem(wndHandler,wndControl) bItemSelected = false self:MLLRecipientDeselected() self:MLLPopulateItems(true) self.nSelectedItem = nil end function MasterLoot:MLLGetSuggestestedLooters(tLooters,item) local tS = {} local tR = {} local bWantEsp = true local bWantWar = true local bWantSpe = true local bWantMed = true local bWantSta = true local bWantEng = true if string.find(item:GetName(),"Prägung") or string.find(item:GetName(),"Imprint") or item:IsEquippable() then local tDetails = item:GetDetailedInfo() if tDetails.tPrimary.arClassRequirement then bWantEsp = false bWantWar = false bWantSpe = false bWantMed = false bWantSta = false bWantEng = false for k , class in ipairs(tDetails.tPrimary.arClassRequirement.arClasses) do if class == 1 then bWantWar = true elseif class == 2 then bWantEng = true elseif class == 3 then bWantEsp = true elseif class == 4 then bWantMed = true elseif class == 5 then bWantSta = true elseif class == 7 then bWantSpe = true end end else local strCategory = item:GetItemCategoryName() if strCategory ~= "" then if string.find(strCategory,"Light") then bWantEng = false bWantWar = false bWantSta = false bWantMed = false elseif string.find(strCategory,"Medium") then bWantEng = false bWantWar = false bWantSpe = false bWantEsp = false elseif string.find(strCategory,"Heavy") then bWantEsp = false bWantSpe = false bWantSta = false bWantMed = false end if string.find(strCategory,"Psyblade") or string.find(strCategory,"Heavy Gun") or string.find(strCategory,"Pistols") or string.find(strCategory,"Claws") or string.find(strCategory,"Greatsword") or string.find(strCategory,"Resonators") then bWantEsp = false bWantWar = false bWantSpe = false bWantMed = false bWantSta = false bWantEng = false end if string.find(strCategory,"Psyblade") then bWantEsp = true elseif string.find(strCategory,"Heavy Gun") then bWantEng = true elseif string.find(strCategory,"Pistols") then bWantSpe = true elseif string.find(strCategory,"Claws") then bWantSta = true elseif string.find(strCategory,"Greatsword") then bWantWar = true elseif string.find(strCategory,"Resonators") then bWantMed = true end end end end for k , looter in pairs(tLooters) do if bWantEsp and ktClassToString[looter:GetClassId()] == "Esper" then table.insert(tS,looter) elseif bWantEng and ktClassToString[looter:GetClassId()] == "Engineer" then table.insert(tS,looter) elseif bWantMed and ktClassToString[looter:GetClassId()] == "Medic" then table.insert(tS,looter) elseif bWantWar and ktClassToString[looter:GetClassId()] == "Warrior" then table.insert(tS,looter) elseif bWantSta and ktClassToString[looter:GetClassId()] == "Stalker" then table.insert(tS,looter) elseif bWantSpe and ktClassToString[looter:GetClassId()] == "Spellslinger" then table.insert(tS,looter) else table.insert(tR,looter) end end return tS , tR end function MasterLoot:MLLPopulateRecipients(lootEntry) self.wndMLL:FindChild("Recipients"):DestroyChildren() local tLootersSuggested , tLootersRest = self:MLLGetSuggestestedLooters(lootEntry.tLooters,lootEntry.itemDrop) table.sort(tLootersSuggested,function (a,b) return a:GetName() < b:GetName() end) table.sort(tLootersRest,function (a,b) return a:GetName() < b:GetName() end) for k , looter in ipairs(tLootersRest) do table.insert(tLootersSuggested,looter) end for k , looter in pairs(tLootersSuggested) do local wnd = Apollo.LoadForm(self.xmlDoc,"LightRecipient",self.wndMLL:FindChild("Recipients"),self) wnd:FindChild("CharacterName"):SetText(looter:GetName()) wnd:FindChild("ClassIcon"):SetSprite(ktClassToIcon[looter:GetClassId()]) wnd:SetData(looter) end self:MLLArrangeRecipients() end function MasterLoot:MLLEnable() self.settings.bLightMode = true self.wndMasterLoot:Show(false,false) self:OnMasterLootUpdate(true) end function MasterLoot:MLLDisable() self.settings.bLightMode = false self.wndMLL:Show(false,false) self:OnMasterLootUpdate() end function MasterLoot:MLLRecipientSelected(wndHandler,wndControl) local l,t,r,b = self.wndMLL:GetAnchorOffsets() self:gracefullyResize(self.wndMLL:FindChild("Assign"),{t=561}) self:gracefullyResize(self.wndMLL,{b=t+nTargetHeight},nil,true) self.wndMLL:FindChild("Assign"):SetText("Assign") bRecipientSelected = true self.unitSelected = wndControl:GetData() end function MasterLoot:MLLRecipientDeselected(wndHandler,wndControl) local l,t,r,b = self.wndMLL:GetAnchorOffsets() self:gracefullyResize(self.wndMLL:FindChild("Assign"),{t=622}) self:gracefullyResize(self.wndMLL,{b=t + nTargetHeight-40},nil,true) self.wndMLL:FindChild("Assign"):SetText("") self.unitSelected = nil end function MasterLoot:MLLKeyDown(nKey) if self.wndMLL:IsShown() and bItemSelected then local l,t,r,b local strKey = ktKeys[nKey] if not strKey then return end for k , child in ipairs(self.wndMLL:FindChild("Recipients"):GetChildren()) do local strName = child:FindChild("CharacterName"):GetText() if string.lower(string.sub(strName,1,1)) == string.lower(strKey) then l,t,r,b = child:GetAnchorOffsets() break end end if t then self.wndMLL:FindChild("Recipients"):SetVScrollPos(t) end end end function MasterLoot:MLLAssign() if self.nSelectedItem and self.unitSelected then GameLib.AssignMasterLoot(self.nSelectedItem,self.unitSelected) bItemSelected = false self:MLLRecipientDeselected() self:MLLPopulateItems(true) end end function MasterLoot:MLLAssignItemAtRandom(wndHandler,wndControl) local tData = wndControl:GetParent():GetData() if tData and tData.tLooters then local luckylooter = self:ChooseRandomLooter(tData) if luckylooter then Apollo.GetAddon("RaidOps"):BidAddPlayerToRandomSkip(luckylooter:GetName()) GameLib.AssignMasterLoot(tData.nLootId,luckylooter) end end end -- Different stuffs function MasterLoot:ChooseRandomLooter(entry) local looters = {} for k , playerUnit in pairs(entry.tLooters or {}) do table.insert(looters,playerUnit) end return looters[math.random(#looters)] end local prevChild function MasterLoot:MLLArrangeRecipients() local list = self.wndMLL:FindChild("Recipients") local children = list:GetChildren() for k , child in ipairs(children) do child:SetAnchorOffsets(-4,0,child:GetWidth()+-4,child:GetHeight()) end for k , child in ipairs(children) do if k > 1 then local l,t,r,b = prevChild:GetAnchorOffsets() child:SetAnchorOffsets(-4,b-10,child:GetWidth()+-4,b+child:GetHeight()-10) end prevChild = child end end function MasterLoot:BidMLSearch(wndHandler,wndControl,strText) strText = self.wndMasterLoot:FindChild("SearchBox"):GetText() local Rops = Apollo.GetAddon("RaidOps") if strText ~= "Search..." then local children = self.wndMasterLoot:FindChild("LooterList"):GetChildren() for k,child in ipairs(children) do child:Show(true,true) end for k,child in ipairs(children) do if not Rops:string_starts(child:FindChild("CharacterName"):GetText(),strText) then child:Show(false,true) end end if wndControl ~= nil and wndControl:GetText() == "" then wndControl:SetText("Search...") end if Rops.tItems["settings"]["ML"].bArrTiles then self.wndMasterLoot_LooterList:ArrangeChildrenTiles() else self.wndMasterLoot_LooterList:ArrangeChildrenVert() end end end function MasterLoot:BQAddItem(wndH,wndC) Apollo.GetAddon("RaidOps"):BQAddItem(wndH,wndC) end function MasterLoot:BQRemItem(wndH,wndC) Apollo.GetAddon("RaidOps"):BQRemItem(wndH,wndC) end
gpl-2.0
zwhfly/openwrt-luci
contrib/luadoc/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
apache-2.0
aqasaeed/me
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
anshkumar/yugioh-glaze
assets/script/c61257789.lua
3
3779
--スターダスト・ドラゴン/バスター function c61257789.initial_effect(c) c:EnableReviveLimit() --Cannot special summon local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(aux.FALSE) c:RegisterEffect(e1) --Negate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(61257789,0)) e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_CHAINING) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c61257789.negcon) e2:SetCost(c61257789.negcost) e2:SetTarget(c61257789.negtg) e2:SetOperation(c61257789.negop) c:RegisterEffect(e2) --Revive local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(61257789,1)) e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetCode(EVENT_PHASE+PHASE_END) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1) e3:SetTarget(c61257789.sumtg) e3:SetOperation(c61257789.sumop) c:RegisterEffect(e3) --Special summon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(61257789,2)) e4:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) e4:SetCode(EVENT_LEAVE_FIELD) e4:SetCondition(c61257789.spcon) e4:SetTarget(c61257789.sptg) e4:SetOperation(c61257789.spop) c:RegisterEffect(e4) end function c61257789.negcon(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) end function c61257789.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end Duel.Release(e:GetHandler(),REASON_COST) end function c61257789.negtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function c61257789.negop(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) if re:GetHandler():IsRelateToEffect(re)then Duel.Destroy(eg,REASON_EFFECT) end e:GetHandler():RegisterFlagEffect(61257789,RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END,0,0) end function c61257789.sumtg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:GetFlagEffect(61257789)>0 and c:IsCanBeSpecialSummoned(e,0,tp,true,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0) end function c61257789.sumop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),0,tp,tp,true,false,POS_FACEUP) end end function c61257789.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_DESTROY) end function c61257789.spfilter(c,e,tp) return c:IsCode(44508094) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c61257789.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c61257789.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c61257789.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c61257789.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c61257789.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
leereilly/hawkthorne-journey
src/vendor/AdvTiledLoader/Tile.lua
3
2502
--------------------------------------------------------------------------------------------------- -- -= Tile =- --------------------------------------------------------------------------------------------------- -- Setup local assert = assert local Tile = {} Tile.__index = Tile -- Creates a new tile and returns it. function Tile:new(id, tileset, quad, width, height, prop) assert( id and tileset and quad, "Tile:new - Needs at least 3 parameters for id, tileset and quad.") local tmp = {} tmp.id = id -- The id of the tile tmp.tileset = tileset -- The tileset this tile belongs to tmp.quad = quad -- The of the tileset that defines the tile tmp.width = width or 0 -- The width of the tile in pixels tmp.height = height or 0 -- The height of the tile in pixels tmp.properties = prop or {} -- The properties of the tile set in Tiled return setmetatable(tmp, Tile) end -- Draws the tile at the given location function Tile:draw(x, y, rotation, scaleX, scaleY, offsetX, offsetY) love.graphics.drawq(self.tileset.image, self.quad, self.tileset.tileoffset.x + x, self.tileset.tileoffset.y + y, rotation, scaleX, scaleY, offsetX, offsetY) end -- Return the Tile class return Tile --[[Copyright (c) 2011 Casey Baxter 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. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. 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.--]]
mit
WAKAMAZU/sile_fe
lua-libraries/repl/plugins/autoreturn.lua
7
1364
-- Copyright (c) 2011-2014 Rob Hoelz <rob@hoelz.ro> -- -- 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. -- A plugin that causes the REPL to automatically return evaluation results function around:compilechunk(orig, chunk) local f, err = orig(self, 'return ' .. chunk) if not f then f, err = orig(self, chunk) end return f, err end
mit
anshkumar/yugioh-glaze
assets/script/c4404099.lua
3
1636
--海底に潜む深海竜 function c4404099.initial_effect(c) --add counter local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(4404099,0)) e1:SetCategory(CATEGORY_COUNTER) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetCode(EVENT_PHASE+PHASE_STANDBY) e1:SetTarget(c4404099.addct) e1:SetOperation(c4404099.addc) c:RegisterEffect(e1) --attackup local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(4404099,1)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetCondition(c4404099.atkcon) e2:SetOperation(c4404099.atkop) c:RegisterEffect(e2) end function c4404099.addct(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_COUNTER,nil,1,0,0x23) end function c4404099.addc(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then e:GetHandler():AddCounter(0x23,1) end end function c4404099.atkcon(e,tp,eg,ep,ev,re,r,rp) local ct=e:GetHandler():GetCounter(0x23) e:SetLabel(ct) return ct>0 and not e:GetHandler():IsLocation(LOCATION_DECK) end function c4404099.filter(c) return c:IsFaceup() and c:IsRace(RACE_FISH+RACE_SEASERPENT) end function c4404099.atkop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c4404099.filter,tp,LOCATION_MZONE,0,nil) local tc=g:GetFirst() while tc do local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(e:GetLabel()*200) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) tc=g:GetNext() end end
gpl-2.0
ynohtna92/SheepTag
game/dota_addons/sheeptag/scripts/vscripts/libraries/popups.lua
9
5511
local popup = {} POPUP_SYMBOL_PRE_PLUS = 0 POPUP_SYMBOL_PRE_MINUS = 1 POPUP_SYMBOL_PRE_SADFACE = 2 POPUP_SYMBOL_PRE_BROKENARROW = 3 POPUP_SYMBOL_PRE_SHADES = 4 POPUP_SYMBOL_PRE_MISS = 5 POPUP_SYMBOL_PRE_EVADE = 6 POPUP_SYMBOL_PRE_DENY = 7 POPUP_SYMBOL_PRE_ARROW = 8 POPUP_SYMBOL_POST_EXCLAMATION = 0 POPUP_SYMBOL_POST_POINTZERO = 1 POPUP_SYMBOL_POST_MEDAL = 2 POPUP_SYMBOL_POST_DROP = 3 POPUP_SYMBOL_POST_LIGHTNING = 4 POPUP_SYMBOL_POST_SKULL = 5 POPUP_SYMBOL_POST_EYE = 6 POPUP_SYMBOL_POST_SHIELD = 7 POPUP_SYMBOL_POST_POINTFIVE = 8 -- e.g. when healed by an ability function PopupHealing(target, amount) PopupNumbers(target, "heal", Vector(0, 255, 0), 1.0, amount, POPUP_SYMBOL_PRE_PLUS, nil) end -- e.g. the popup you get when you suddenly take a large portion of your health pool in damage at once function PopupDamage(target, amount) PopupNumbers(target, "damage", Vector(255, 0, 0), 1.0, amount, nil, POPUP_SYMBOL_POST_DROP) end -- e.g. when dealing critical damage function PopupCriticalDamage(target, amount) PopupNumbers(target, "crit", Vector(255, 0, 0), 1.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end -- e.g. when taking damage over time from a poison type spell function PopupDamageOverTime(target, amount) PopupNumbers(target, "poison", Vector(215, 50, 248), 1.0, amount, nil, POPUP_SYMBOL_POST_EYE) end -- e.g. when blocking damage with a stout shield function PopupDamageBlock(target, amount) PopupNumbers(target, "block", Vector(255, 255, 255), 1.0, amount, POPUP_SYMBOL_PRE_MINUS, nil) end -- e.g. when last-hitting a creep function PopupGoldGain(target, amount) PopupNumbers(target, "gold", Vector(255, 200, 33), 2.0, amount, POPUP_SYMBOL_PRE_PLUS, nil) end -- e.g. when missing uphill function PopupMiss(target) PopupNumbers(target, "miss", Vector(255, 0, 0), 1.0, nil, POPUP_SYMBOL_PRE_MISS, nil) end function PopupExperience(target, amount) PopupNumbers(target, "miss", Vector(154, 46, 254), 1.0, amount, POPUP_SYMBOL_PRE_PLUS, nil) end function PopupMana(target, amount) PopupNumbers(target, "heal", Vector(0, 176, 246), 1.0, amount, POPUP_SYMBOL_PRE_PLUS, nil) end function PopupHealthTome(target, amount) PopupNumbers(target, "miss", Vector(255, 255, 255), 1.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end function PopupStrTome(target, amount) PopupNumbers(target, "miss", Vector(255, 0, 0), 1.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end function PopupAgiTome(target, amount) PopupNumbers(target, "miss", Vector(0, 255, 0), 1.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end function PopupIntTome(target, amount) PopupNumbers(target, "miss", Vector(0, 176, 246), 1.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end function PopupHPRemovalDamage(target, amount) PopupNumbers(target, "crit", Vector(154, 46, 254), 3.0, amount, nil, POPUP_SYMBOL_POST_LIGHTNING) end function PopupLumber(target, amount) PopupNumbers(target, "damage", Vector(10, 200, 90), 3.0, amount, POPUP_SYMBOL_PRE_PLUS, nil) end -- Customizable version. function PopupNumbers(target, pfx, color, lifetime, number, presymbol, postsymbol) local pfxPath = string.format("particles/msg_fx/msg_%s.vpcf", pfx) local pidx if pfx == "gold" or pfx == "luber" then pidx = ParticleManager:CreateParticleForTeam(pfxPath, PATTACH_ABSORIGIN_FOLLOW, target, target:GetTeamNumber()) else pidx = ParticleManager:CreateParticle(pfxPath, PATTACH_ABSORIGIN_FOLLOW, target) end local digits = 0 if number ~= nil then digits = #tostring(number) end if presymbol ~= nil then digits = digits + 1 end if postsymbol ~= nil then digits = digits + 1 end ParticleManager:SetParticleControl(pidx, 1, Vector(tonumber(presymbol), tonumber(number), tonumber(postsymbol))) ParticleManager:SetParticleControl(pidx, 2, Vector(lifetime, digits, 0)) ParticleManager:SetParticleControl(pidx, 3, color) end function PopupMultiplier(target, number) local particleName = "particles/custom/alchemist_unstable_concoction_timer.vpcf" local preSymbol = 0 --none local postSymbol = 4 --crit local digits = string.len(number)+1 local targetPos = target:GetAbsOrigin() local particle = ParticleManager:CreateParticle( particleName, PATTACH_CUSTOMORIGIN, target ) ParticleManager:SetParticleControl(particle, 0, Vector(targetPos.x, targetPos.y, targetPos.z+322)) ParticleManager:SetParticleControl( particle, 1, Vector( preSymbol, number, postSymbol) ) ParticleManager:SetParticleControl( particle, 2, Vector( digits, 0, 0) ) end function PopupLegion(target, number) local particleName = "particles/custom/legion_commander_duel_text.vpcf" local digits = string.len(number) local targetPos = target:GetAbsOrigin() local particle = ParticleManager:CreateParticle( particleName, PATTACH_CUSTOMORIGIN, target ) ParticleManager:SetParticleControl( particle, 1, Vector( 10, number, 0) ) ParticleManager:SetParticleControl( particle, 2, Vector( digits, 0, 0) ) ParticleManager:SetParticleControl( particle, 3, Vector(targetPos.x, targetPos.y, targetPos.z+322) ) end function PopupKillbanner(target, name) -- Possible names: firstblood, doublekill, triplekill, rampage, multikill_generic local particleName = "particles/econ/events/killbanners/screen_killbanner_compendium14_"..name..".vpcf" local particle = ParticleManager:CreateParticle( particleName, PATTACH_EYES_FOLLOW, target ) end return popups
gpl-2.0
freifunk-gluon/luci
applications/luci-diag-devinfo/luasrc/model/cbi/luci_diag/smap_devinfo.lua
141
1038
--[[ smap_devinfo - SIP Device Information (c) 2009 Daniel Dickinson 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$ ]]-- require("luci.i18n") require("luci.util") require("luci.sys") require("luci.model.uci") require("luci.controller.luci_diag.smap_common") require("luci.controller.luci_diag.devinfo_common") local debug = false m = SimpleForm("luci-smap-to-devinfo", translate("SIP Device Information"), translate("Scan for supported SIP devices on specified networks.")) m.reset = false m.submit = false local outnets = luci.controller.luci_diag.smap_common.get_params() luci.controller.luci_diag.devinfo_common.run_processes(outnets, luci.controller.luci_diag.smap_common.command_function) luci.controller.luci_diag.devinfo_common.parse_output(m, outnets, true, "smap", false, debug) luci.controller.luci_diag.smap_common.action_links(m, false) return m
apache-2.0
anshkumar/yugioh-glaze
assets/script/c25642998.lua
9
1264
--ポセイドン・ウェーブ function c25642998.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DAMAGE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetCondition(c25642998.condition) e1:SetTarget(c25642998.target) e1:SetOperation(c25642998.activate) c:RegisterEffect(e1) end function c25642998.condition(e,tp,eg,ep,ev,re,r,rp) return tp~=Duel.GetTurnPlayer() end function c25642998.dfilter(c) return c:IsFaceup() and c:IsRace(RACE_FISH+RACE_SEASERPENT+RACE_AQUA) end function c25642998.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local tg=Duel.GetAttacker() if chkc then return chkc==tg end if chk==0 then return tg:IsOnField() and tg:IsCanBeEffectTarget(e) end Duel.SetTargetCard(tg) local dam=Duel.GetMatchingGroupCount(c25642998.dfilter,tp,LOCATION_MZONE,0,nil)*800 if dam>0 then Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam) end end function c25642998.activate(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and Duel.NegateAttack() then local dam=Duel.GetMatchingGroupCount(c25642998.dfilter,tp,LOCATION_MZONE,0,nil)*800 if dam>0 then Duel.Damage(1-tp,dam,REASON_EFFECT) end end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c7076131.lua
3
1272
--ロスト・ネクスト function c7076131.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(c7076131.target) e1:SetOperation(c7076131.activate) c:RegisterEffect(e1) end function c7076131.filter(c,code) return c:IsCode(code) and c:IsAbleToGrave() end function c7076131.tgfilter(c,tp) return c:IsFaceup() and Duel.IsExistingMatchingCard(c7076131.filter,tp,LOCATION_DECK,0,1,nil,c:GetCode()) end function c7076131.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c7076131.tgfilter(chkc,tp) end if chk==0 then return Duel.IsExistingTarget(c7076131.tgfilter,tp,LOCATION_MZONE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c7076131.tgfilter,tp,LOCATION_MZONE,0,1,1,nil,tp) end function c7076131.activate(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c7076131.filter,tp,LOCATION_DECK,0,1,1,nil,tc:GetCode()) Duel.SendtoGrave(g,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c55624610.lua
3
1569
--スクラップ・ハンター function c55624610.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(55624610,0)) e1:SetCategory(CATEGORY_DESTROY+CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetTarget(c55624610.destg) e1:SetOperation(c55624610.desop) c:RegisterEffect(e1) end function c55624610.desfilter(c) return c:IsFaceup() and c:IsSetCard(0x24) and c:IsDestructable() end function c55624610.sfilter(c) return c:IsType(TYPE_TUNER) and c:IsAbleToGrave() end function c55624610.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c55624610.desfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c55624610.desfilter,tp,LOCATION_MZONE,0,1,e:GetHandler()) and Duel.IsExistingMatchingCard(c55624610.sfilter,tp,LOCATION_DECK,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c55624610.desfilter,tp,LOCATION_MZONE,0,1,1,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function c55624610.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=Duel.SelectMatchingCard(tp,c55624610.sfilter,tp,LOCATION_DECK,0,1,1,nil) Duel.SendtoGrave(sg,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c34475451.lua
3
1312
--工作列車シグナル・レッド function c34475451.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(34475451,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c34475451.condition) e1:SetTarget(c34475451.target) e1:SetOperation(c34475451.operation) c:RegisterEffect(e1) end function c34475451.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetAttacker():GetControler()~=tp end function c34475451.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0) end function c34475451.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)~=0 then local a=Duel.GetAttacker() if a:IsAttackable() and not a:IsImmuneToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE) e1:SetValue(1) e1:SetReset(RESET_PHASE+PHASE_DAMAGE) c:RegisterEffect(e1) Duel.CalculateDamage(a,c) end end end
gpl-2.0
assassinboy208/eagleTG
plugins/id.lua
226
4260
local 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 local function returnids(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'IDs for chat '..chatname ..' ('..chat_id..')\n' ..'There are '..result.members_num..' members' ..'\n---------\n' for k,v in pairs(result.members) do text = text .. v.print_name .. " (user#id" .. v.id .. ")\n" end send_large_msg(receiver, text) end local function run(msg, matches) local receiver = get_receiver(msg) if matches[1] == "!id" then local text = user_print_name(msg.from) .. ' (user#id' .. msg.from.id .. ')' if is_chat_msg(msg) then text = text .. "\nYou are in group " .. user_print_name(msg.to) .. " (chat#id" .. msg.to.id .. ")" end return text elseif matches[1] == "chat" then -- !ids? (chat) (%d+) if matches[2] and is_sudo(msg) then local chat = 'chat#id'..matches[2] chat_info(chat, returnids, {receiver=receiver}) else if not is_chat_msg(msg) then return "You are not in a group." end local chat = get_receiver(msg) chat_info(chat, returnids, {receiver=receiver}) end elseif matches[1] == "member" and matches[2] == "@" then local nick = matches[3] local chat = get_receiver(msg) if not is_chat_msg(msg) then return "You are not in a group." end chat_info(chat, function (extra, success, result) local receiver = extra.receiver local nick = extra.nick local found for k,user in pairs(result.members) do if user.username == nick then found = user end end if not found then send_msg(receiver, "User not found on this chat.", ok_cb, false) else local text = "ID: "..found.id send_msg(receiver, text, ok_cb, false) end end, {receiver=chat, nick=nick}) elseif matches[1] == "members" and matches[2] == "name" then local text = matches[3] local chat = get_receiver(msg) if not is_chat_msg(msg) then return "You are not in a group." end chat_info(chat, function (extra, success, result) local members = result.members local receiver = extra.receiver local text = extra.text local founds = {} for k,member in pairs(members) do local fields = {'first_name', 'print_name', 'username'} for k,field in pairs(fields) do if member[field] and type(member[field]) == "string" then if member[field]:match(text) then local id = tostring(member.id) founds[id] = member end end end end if next(founds) == nil then -- Empty table send_msg(receiver, "User not found on this chat.", ok_cb, false) else local text = "" for k,user in pairs(founds) do local first_name = user.first_name or "" local print_name = user.print_name or "" local user_name = user.user_name or "" local id = user.id or "" -- This would be funny text = text.."First name: "..first_name.."\n" .."Print name: "..print_name.."\n" .."User name: "..user_name.."\n" .."ID: "..id end send_msg(receiver, text, ok_cb, false) end end, {receiver=chat, text=text}) end end return { description = "Know your id or the id of a chat members.", usage = { "!id: Return your ID and the chat id if you are in one.", "!ids chat: Return the IDs of the current chat members.", "!ids chat <chat_id>: Return the IDs of the <chat_id> members.", "!id member @<user_name>: Return the member @<user_name> ID from the current chat", "!id members name <text>: Search for users with <text> on first_name, print_name or username on current chat" }, patterns = { "^!id$", "^!ids? (chat) (%d+)$", "^!ids? (chat)$", "^!id (member) (@)(.+)", "^!id (members) (name) (.+)" }, run = run }
gpl-2.0
johnparker007/mame
scripts/src/osd/windows.lua
5
7475
-- license:BSD-3-Clause -- copyright-holders:MAMEdev Team --------------------------------------------------------------------------- -- -- windows.lua -- -- Rules for the building for Windows -- --------------------------------------------------------------------------- dofile("modules.lua") function maintargetosdoptions(_target,_subtarget) osdmodulestargetconf() configuration { "mingw*" } links { "mingw32", } configuration { } if _OPTIONS["DIRECTINPUT"] == "8" then links { "dinput8", } else links { "dinput", } end if _OPTIONS["USE_SDL"] == "1" then links { "SDL.dll", } end links { "comctl32", "comdlg32", "psapi", "ole32", "shlwapi", } end newoption { trigger = "DIRECTINPUT", description = "Minimum DirectInput version to support", allowed = { { "7", "Support DirectInput 7 or later" }, { "8", "Support DirectInput 8 or later" }, }, } if not _OPTIONS["DIRECTINPUT"] then _OPTIONS["DIRECTINPUT"] = "8" end newoption { trigger = "USE_SDL", description = "Enable SDL sound output", allowed = { { "0", "Disable SDL sound output" }, { "1", "Enable SDL sound output" }, }, } if not _OPTIONS["USE_SDL"] then _OPTIONS["USE_SDL"] = "0" end newoption { trigger = "CYGWIN_BUILD", description = "Build with Cygwin tools", allowed = { { "0", "Build with MinGW tools" }, { "1", "Build with Cygwin tools" }, }, } if not _OPTIONS["CYGWIN_BUILD"] then _OPTIONS["CYGWIN_BUILD"] = "0" end if _OPTIONS["CYGWIN_BUILD"] == "1" then buildoptions { "-mmo-cygwin", } linkoptions { "-mno-cygwin", } end project ("qtdbg_" .. _OPTIONS["osd"]) uuid (os.uuid("qtdbg_" .. _OPTIONS["osd"])) kind (LIBTYPE) dofile("windows_cfg.lua") includedirs { MAME_DIR .. "src/emu", MAME_DIR .. "src/devices", -- accessing imagedev from debugger MAME_DIR .. "src/osd", MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", MAME_DIR .. "src/osd/modules/render", MAME_DIR .. "3rdparty", } qtdebuggerbuild() project ("osd_" .. _OPTIONS["osd"]) uuid (os.uuid("osd_" .. _OPTIONS["osd"])) kind (LIBTYPE) dofile("windows_cfg.lua") osdmodulesbuild() defines { "DIRECT3D_VERSION=0x0900", } if _OPTIONS["DIRECTINPUT"] == "8" then defines { "DIRECTINPUT_VERSION=0x0800", } else defines { "DIRECTINPUT_VERSION=0x0700", } end includedirs { MAME_DIR .. "src/emu", MAME_DIR .. "src/devices", -- accessing imagedev from debugger MAME_DIR .. "src/osd", MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", MAME_DIR .. "src/osd/modules/file", MAME_DIR .. "src/osd/modules/render", MAME_DIR .. "3rdparty", } includedirs { MAME_DIR .. "src/osd/windows", } files { MAME_DIR .. "src/osd/modules/render/d3d/d3dhlsl.cpp", MAME_DIR .. "src/osd/modules/render/d3d/d3dcomm.h", MAME_DIR .. "src/osd/modules/render/d3d/d3dhlsl.h", MAME_DIR .. "src/osd/modules/render/drawd3d.cpp", MAME_DIR .. "src/osd/modules/render/drawd3d.h", MAME_DIR .. "src/osd/modules/render/drawgdi.cpp", MAME_DIR .. "src/osd/modules/render/drawgdi.h", MAME_DIR .. "src/osd/modules/render/drawnone.cpp", MAME_DIR .. "src/osd/modules/render/drawnone.h", MAME_DIR .. "src/osd/windows/video.cpp", MAME_DIR .. "src/osd/windows/video.h", MAME_DIR .. "src/osd/windows/window.cpp", MAME_DIR .. "src/osd/windows/window.h", MAME_DIR .. "src/osd/modules/osdwindow.cpp", MAME_DIR .. "src/osd/modules/osdwindow.h", MAME_DIR .. "src/osd/windows/winmenu.cpp", MAME_DIR .. "src/osd/windows/winmain.cpp", MAME_DIR .. "src/osd/windows/winmain.h", MAME_DIR .. "src/osd/osdepend.h", MAME_DIR .. "src/osd/modules/debugger/win/consolewininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/consolewininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/debugbaseinfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/debugbaseinfo.h", MAME_DIR .. "src/osd/modules/debugger/win/debugviewinfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/debugviewinfo.h", MAME_DIR .. "src/osd/modules/debugger/win/debugwininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/debugwininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/disasmbasewininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/disasmbasewininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/disasmviewinfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/disasmviewinfo.h", MAME_DIR .. "src/osd/modules/debugger/win/disasmwininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/disasmwininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/editwininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/editwininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/logwininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/logwininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/logviewinfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/logviewinfo.h", MAME_DIR .. "src/osd/modules/debugger/win/memoryviewinfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/memoryviewinfo.h", MAME_DIR .. "src/osd/modules/debugger/win/memorywininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/memorywininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/pointswininfo.cpp", MAME_DIR .. "src/osd/modules/debugger/win/pointswininfo.h", MAME_DIR .. "src/osd/modules/debugger/win/uimetrics.cpp", MAME_DIR .. "src/osd/modules/debugger/win/uimetrics.h", MAME_DIR .. "src/osd/modules/debugger/win/debugwin.h", } project ("ocore_" .. _OPTIONS["osd"]) uuid (os.uuid("ocore_" .. _OPTIONS["osd"])) kind (LIBTYPE) removeflags { "SingleOutputDir", } dofile("windows_cfg.lua") includedirs { MAME_DIR .. "3rdparty", MAME_DIR .. "src/emu", MAME_DIR .. "src/osd", MAME_DIR .. "src/osd/modules/file", MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", } BASE_TARGETOS = "win32" SDLOS_TARGETOS = "win32" includedirs { MAME_DIR .. "src/osd/windows", } files { MAME_DIR .. "src/osd/eigccppc.h", MAME_DIR .. "src/osd/eigccx86.h", MAME_DIR .. "src/osd/eivc.h", MAME_DIR .. "src/osd/eivcx86.h", MAME_DIR .. "src/osd/eminline.h", MAME_DIR .. "src/osd/osdcomm.h", MAME_DIR .. "src/osd/osdcore.cpp", MAME_DIR .. "src/osd/osdcore.h", MAME_DIR .. "src/osd/strconv.cpp", MAME_DIR .. "src/osd/strconv.h", MAME_DIR .. "src/osd/osdsync.cpp", MAME_DIR .. "src/osd/osdsync.h", MAME_DIR .. "src/osd/windows/main.cpp", MAME_DIR .. "src/osd/windows/winutf8.cpp", MAME_DIR .. "src/osd/windows/winutf8.h", MAME_DIR .. "src/osd/windows/winutil.cpp", MAME_DIR .. "src/osd/windows/winutil.h", MAME_DIR .. "src/osd/modules/osdmodule.cpp", MAME_DIR .. "src/osd/modules/osdmodule.h", MAME_DIR .. "src/osd/modules/file/windir.cpp", MAME_DIR .. "src/osd/modules/file/winfile.cpp", MAME_DIR .. "src/osd/modules/file/winfile.h", MAME_DIR .. "src/osd/modules/file/winptty.cpp", MAME_DIR .. "src/osd/modules/file/winsocket.cpp", MAME_DIR .. "src/osd/modules/lib/osdlib_win32.cpp", } -------------------------------------------------- -- ledutil -------------------------------------------------- if _OPTIONS["with-tools"] then project("ledutil") uuid ("061293ca-7290-44ac-b2b5-5913ae8dc9c0") kind "ConsoleApp" flags { "Symbols", -- always include minimum symbols for executables } if _OPTIONS["SEPARATE_BIN"]~="1" then targetdir(MAME_DIR) end links { "ocore_" .. _OPTIONS["osd"], } includedirs { MAME_DIR .. "src/osd", } files { MAME_DIR .. "src/osd/windows/ledutil.cpp", } end
gpl-2.0