content stringlengths 5 1.05M |
|---|
local matrix = {}
function matrix.T(a: table)
local m: integer, n: integer, x: table = #a, #a[1], {};
for i = 1, n do
local xi: number[] = table.numarray(n, 0.0)
x[i] = xi
for j = 1, m do xi[j] = @number (a[j][i]) end
end
return x;
end
function matrix.mul(a: table, b: table)
assert(@integer(#a[1]) == #b);
local m: integer, n: integer, p: integer, x: table = #a, #a[1], #b[1], {};
local c: table = matrix.T(b); -- transpose for efficiency
for i = 1, m do
local xi: number[] = table.numarray(p, 0.0)
x[i] = xi
for j = 1, p do
local sum: number, ai: number[], cj: number[] = 0.0, @number[](a[i]), @number[](c[j]);
-- for luajit, caching c[j] or not makes no difference; lua is not so clever
for k = 1, n do sum = sum + ai[k] * cj[k] end
xi[j] = sum;
end
end
return x;
end
function matrix.gen(n: integer)
local a: table, tmp: number = {}, 1. / n / n;
for i = 1, n do
local ai: number[] = table.numarray(n, 0.0)
a[i] = ai
for j = 1, n do
ai[j] = tmp * (i - j) * (i + j - 2)
end
end
return a;
end
return matrix
|
local Log = {
Created = false,
Create = function (self, name, filename)
local log = {}
setmetatable(log, self)
log.Name = name
log.Filename = filename
log.Created = false
return log
end,
CreateLog = function (self, clear)
if self.Created then
return
end
clear = clear or 0
TextLogCreate(self.Name, 1)
self:SetEnabled(true)
if clear then
self:Clear()
end
TextLogSetIncrementalSaving(self.Name, true, self.Filename)
self.Created = true
end,
SetEnabled = function (self, enabled)
TextLogSetEnabled(self.Name, enabled)
end,
Clear = function (self)
TextLogClear(self.Name)
end
}
Log.__index = Log
OpenCore:RegisterClass("Log.Log", Log) |
---@meta
--=== mcp4725 ===
---@class mcp4725
---@field PWRDN_NONE integer
---@field PWRDN_1K integer
---@field PWRDN_100K integer
---@field PWRDN_500K integer
mcp4725 = {}
---Gets contents of the dac register and EEPROM.
---@param tbl table @{[a0], [a1], [a2]}
--- - **A0** Address bit 0. This bit is user configurable via MCP4725 pin 6(A0).\
---(valid states: 0 or 1) (default: 0)
--- - **A1** Address bit 1. This bit is hard-wired during manufacture.\
---(valid states: 0 or 1) (default: 0)
--- - **A2** Address bit 2. This bit is hard-wired during manufacture.\
---(valid states: 0 or 1) (default: 0)
---@return number cur_pwrdn @Current power down configuration value.
---@return number cur_val @Current value stored in dac register.
---@return number eeprom_pwrdn @Power down configuration stored in EEPROM.
---@return number eeprom_val @DAC value stored in EEPROM.
---@return number eeprom_state @EEPROM write status
--- - 0 - EEPROM write is incomplete.
--- - 1 - EEPROM write has completed
---@return number por_state @Power-On-Reset status;
--- - 0 - The MCP4725 is performing reset and is not ready.
--- - 1 - The MCP4725 has successfully performed reset.
function mcp4725.read(tbl) end
---Write configuration to dac register or dac register and eeprom.
---@param tbl table @{[a0], [a1], [a2], value, [pwrdn], [save]}
--- - **A0** Address bit 0. This bit is user configurable via MCP4725 pin 6(A0).\
---(valid states: 0 or 1) (default: 0)
--- - **A1** Address bit 1. This bit is hard-wired during manufacture.\
---(valid states: 0 or 1) (default: 0)
--- - **A2** Address bit 2. This bit is hard-wired during manufacture.\
---(valid states: 0 or 1) (default: 0)
--- - **value** The value to be used to configure DAC (and EEPROM). (Range: 0 - 4095)
--- - **pwrdn** Set power down bits.
--- - mcp4725.PWRDN_NONE MCP4725 - output enabled. (Default)
--- - mcp4725.PWRDN_1K MCP4725 - output disabled,\
---output pulled to ground via 1K restistor.
--- - mcp4725.PWRDN_100K MCP4725 - output disabled,\
---output pulled to ground via 100K restistor.
--- - mcp4725.PWRDN_500K MCP4725 - output disabled,\
---output pulled to ground via 500K restistor.
--- - **save** Save pwrdn and dac values to EEPROM. (Values are loaded on power-up\
---or during reset.)
--- - `true` Save configuration to EEPROM.
--- - `false` Do not save configuration to EEPROM. (Default)
---@return nil
function mcp4725.write(tbl) end
|
local utils = require"test_utils"
local JSON = require"JSON"
local sh, stdout, stderr, sleep, sh_ex, sh_until_ok =
utils.sh, utils.stdout, utils.stderr, utils.sleep, utils.sh_ex, utils.sh_until_ok
local pl_file = require"pl.file"
local pl_path = require "pl.path"
local pl_tmpname = pl_path.tmpname
local _M = {}
local kong_image = "kong:2.0.4-alpine"
local postgress_image = "postgres:9.5"
local openresty_image = "openresty/openresty:alpine"
local host_git_root = os.getenv"HOST_GIT_ROOT"
local git_root = os.getenv"GIT_ROOT"
local gg_image_id = os.getenv"GG_IMAGE_ID"
_M.docker_unique_network = function()
local ctx = _G.ctx
local unique_network_name = stdout("uuidgen")
sh("docker network create --driver bridge ", unique_network_name)
ctx.finalizeres[#ctx.finalizeres + 1] = function()
sh("docker network rm ", unique_network_name)
end
_G.ctx.network_name = unique_network_name
end
local function build_plugins_list(plugins)
assert(type(plugins) == "table")
local plugin_list = {}
plugin_list[1] = [[bundled]]
for k,v in pairs(plugins) do
plugin_list[#plugin_list + 1] = k
end
local result = table.concat(plugin_list, ",")
print("plugin list: ", result)
return result
end
local function build_plugins_volumes(plugins)
assert(type(plugins) == "table")
local items = {}
for k,v in pairs(plugins) do
items[#items + 1] =
" -v " .. v .. ":" .. "/usr/local/openresty/lualib/kong/plugins/" .. k .. " "
end
local result = table.concat(items)
print("plugin volumes: ", result)
return result
end
local function build_modules_volumes(modules)
assert(type(modules) == "table")
local items = {}
for k,v in pairs(modules) do
items[#items + 1] =
" -v " .. v .. ":" .. "/usr/local/openresty/lualib/" .. k .. " "
end
local result = table.concat(items)
print("modules volumes: ", result)
return result
end
local function build_volumes(volumes)
assert(type(volumes) == "table")
local items = {}
for k,v in pairs(volumes) do
items[#items + 1] =
" -v " .. v .. ":" .. k .. " "
end
local result = table.concat(items)
print("volumes: ", result)
return result
end
local function check_container_is_running(id, name)
-- https://stackoverflow.com/questions/24544288/how-to-detect-if-docker-run-succeeded-programmatically
sleep(1)
local ok = stdout("docker inspect -f {{.State.Running}} ", id)
if ok == "false" then
ctx.finalizeres[#ctx.finalizeres + 1] = function()
sh("docker rm -v ", id, " || true")
end
error(name .. " container failed to start")
end
ctx.finalizeres[#ctx.finalizeres + 1] = function()
sh("docker stop ", id, " || true")
sh("docker rm -v ", id, " || true")
end
end
_M.kong_postgress_custom_plugins = function(opts)
local ctx = _G.ctx
assert(ctx.network_name)
ctx.postgress_id = stdout("docker run -p 5432 -d ",
" --network=", ctx.network_name,
" -e POSTGRES_USER=kong ",
" -e POSTGRES_DB=kong ",
" -e POSTGRES_HOST_AUTH_METHOD=trust",
" --name kong-database ", -- TODO avoid hardcoded names
opts.postgress_image or postgress_image
)
check_container_is_running(ctx.postgress_id, "postgress")
-- TODO use Postgress client and try to connect
sleep(30)
local plugins = opts.plugins or {}
local modules = opts.modules or {}
local volumes = opts.volumes or {}
-- run in foreground to get a chance to finish
sh("docker run --rm ",
" --network=", ctx.network_name,
" -e KONG_DATABASE=postgres ",
" -e KONG_PG_HOST=kong-database ",
" -e KONG_LOG_LEVEL=debug ",
" -e KONG_NGINX_HTTP_LUA_SHARED_DICT=\"gluu_metrics 1m\" ",
" -e KONG_PROXY_ACCESS_LOG=/dev/stdout ",
" -e KONG_ADMIN_ACCESS_LOG=/dev/stdout ",
" -e KONG_PROXY_ERROR_LOG=/dev/stderr ",
" -e KONG_ADMIN_ERROR_LOG=/dev/stderr ",
" -e KONG_PLUGINS=", build_plugins_list(plugins), " ",
build_plugins_volumes(plugins),
build_modules_volumes(modules),
build_volumes(volumes),
opts.kong_image or kong_image,
" kong migrations bootstrap"
)
-- TODO something better?
sleep(2)
ctx.kong_id = stdout("docker run -p 8000 -p 8001 -d ",
" --network=", ctx.network_name,
" -e KONG_NGINX_WORKER_PROCESSES=1 ", -- important! oxd-mock logic assume one worker
" -e KONG_NGINX_HTTP_LUA_SHARED_DICT=\"gluu_metrics 1m\" ",
" -e KONG_DATABASE=postgres ",
" -e KONG_PG_HOST=kong-database ",
" -e KONG_PG_DATABASE=kong ",
" -e KONG_ADMIN_LISTEN=0.0.0.0:8001 ",
" -e KONG_LOG_LEVEL=debug ",
" -e KONG_PROXY_ACCESS_LOG=/dev/stdout ",
" -e KONG_ADMIN_ACCESS_LOG=/dev/stdout ",
" -e KONG_PROXY_ERROR_LOG=/dev/stderr ",
" -e KONG_ADMIN_ERROR_LOG=/dev/stderr ",
" -e KONG_PLUGINS=", build_plugins_list(plugins), " ",
build_plugins_volumes(plugins),
build_modules_volumes(modules),
build_volumes(volumes),
opts.kong_image or kong_image
)
check_container_is_running(ctx.kong_id, "kong")
ctx.kong_admin_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8001/tcp\") 0).HostPort}}' ", ctx.kong_id)
ctx.kong_proxy_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8000/tcp\") 0).HostPort}}' ", ctx.kong_id)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_admin_port)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_proxy_port)
end
_M.kong_postgress = function()
local ctx = _G.ctx
assert(ctx.network_name)
ctx.postgress_id = stdout("docker run -p 5432 -d ",
" --network=", ctx.network_name,
" -e POSTGRES_USER=kong ",
" -e POSTGRES_DB=kong ",
" -e POSTGRES_HOST_AUTH_METHOD=trust",
" --name kong-database ", -- TODO avoid hardcoded names
postgress_image
)
check_container_is_running(ctx.postgress_id, "postgress")
-- TODO use Postgress client and try to connect
sleep(30)
-- run in foreground to get a chance to finish
sh("docker run --rm ",
" --network=", ctx.network_name,
" -e KONG_DATABASE=postgres ",
" -e KONG_PG_HOST=kong-database ",
" -e KONG_LOG_LEVEL=debug ",
gg_image_id,
" kong migrations bootstrap"
)
-- TODO something better?
sleep(2)
ctx.kong_id = stdout("docker run -p 8000 -p 8001 -d ",
" --network=", ctx.network_name,
" -e KONG_NGINX_WORKER_PROCESSES=1 ", -- important! oxd-mock logic assume one worker
" -e KONG_DATABASE=postgres ",
" -e KONG_PG_HOST=kong-database ",
" -e KONG_PG_DATABASE=kong ",
" -e KONG_ADMIN_LISTEN=0.0.0.0:8001 ",
" -e KONG_LOG_LEVEL=debug ",
gg_image_id
)
check_container_is_running(ctx.kong_id, "kong")
ctx.kong_admin_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8001/tcp\") 0).HostPort}}' ", ctx.kong_id)
ctx.kong_proxy_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8000/tcp\") 0).HostPort}}' ", ctx.kong_id)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_admin_port)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_proxy_port)
end
_M.gg_db_less = function(config, plugins, wait_for_stop, injected_kong_proxy, kong2)
local kong_id_key = kong2 and "kong_id2" or "kong_id"
local config_json_tmp_filename = utils.dump_table_to_tmp_json_file(config)
ctx.finalizeres[#ctx.finalizeres + 1] = function()
pl_file.delete(config_json_tmp_filename)
end
local injected_kong_proxy_command
if injected_kong_proxy then
local injected_kong_proxy_tmp_file_name = utils.dump_text_to_tmp_file(injected_kong_proxy)
injected_kong_proxy_command = " -v " .. injected_kong_proxy_tmp_file_name .. ":/injected_http.conf "
ctx.finalizeres[#ctx.finalizeres + 1] = function()
pl_file.delete(injected_kong_proxy_tmp_file_name)
end
end
ctx[kong_id_key] = stdout("docker run -p 8000 -p 8001 -d ",
" --network=", ctx.network_name,
" -e KONG_NGINX_WORKER_PROCESSES=1 ", -- important! oxd-mock logic assume one worker
" -e KONG_DECLARATIVE_CONFIG=/config.yml ",
" -v ", config_json_tmp_filename, ":/config.yml ",
injected_kong_proxy and injected_kong_proxy_command or "",
injected_kong_proxy and " -e KONG_NGINX_PROXY_INCLUDE=/injected_http.conf" or "",
" -e KONG_DATABASE=off ",
" -e KONG_ADMIN_LISTEN=0.0.0.0:8001 ",
" -e KONG_PROXY_LISTEN=0.0.0.0:8000 ",
" -e KONG_LOG_LEVEL=debug ",
plugins and build_plugins_volumes(plugins) or "",
gg_image_id
)
if wait_for_stop then
sh_ex("docker wait ", ctx[kong_id_key])
return
end
check_container_is_running(ctx[kong_id_key], "kong")
if not kong2 then
ctx.kong_admin_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8001/tcp\") 0).HostPort}}' ", ctx[kong_id_key])
ctx.kong_proxy_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8000/tcp\") 0).HostPort}}' ", ctx[kong_id_key])
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_admin_port)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_proxy_port)
return
end
ctx.kong_admin_port2 =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8001/tcp\") 0).HostPort}}' ", ctx[kong_id_key])
ctx.kong_proxy_port2 =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8000/tcp\") 0).HostPort}}' ", ctx[kong_id_key])
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_admin_port2)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.kong_proxy_port2)
end
_M.backend = function(image)
local ctx = _G.ctx
ctx.backend_id = stdout("docker run -p 80 -d ",
" --network=", ctx.network_name,
" -v ", ctx.host_git_root, "/t/lib/backend.nginx:/usr/local/openresty/nginx/conf/nginx.conf:ro ",
" --net-alias=backend ",
image or openresty_image
)
check_container_is_running(ctx.backend_id, "backend")
ctx.backend_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"80/tcp\") 0).HostPort}}' ", ctx.backend_id)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.backend_port)
end
_M.oxd_mock = function(model, image)
local ctx = _G.ctx
ctx.oxd_id = stdout("docker run -p 80 -d ",
" --network=", ctx.network_name,
" -v ", ctx.host_git_root, "/t/lib/oxd-mock.lua:/usr/local/openresty/lualib/gluu/oxd-mock.lua:ro ",
" -v ", ctx.host_git_root, "/t/lib/oxd-mock.nginx:/usr/local/openresty/nginx/conf/nginx.conf:ro ",
" -v ", model, ":/usr/local/openresty/lualib/gluu/oxd-model.lua:ro ",
" -v ", ctx.host_git_root, "/third-party/lua-resty-jwt/lib/resty/jwt.lua:/usr/local/openresty/lualib/resty/jwt.lua:ro ",
" -v ", ctx.host_git_root, "/third-party/lua-resty-jwt/lib/resty/evp.lua:/usr/local/openresty/lualib/resty/evp.lua:ro ",
" -v ", ctx.host_git_root, "/third-party/lua-resty-jwt/lib/resty/jwt-validators.lua:/usr/local/openresty/lualib/resty/jwt-validators.lua:ro ",
" -v ", ctx.host_git_root, "/third-party/lua-resty-hmac/lib/resty/hmac.lua:/usr/local/openresty/lualib/resty/hmac.lua:ro ",
" --net-alias=oxd-mock ",
image or openresty_image
)
check_container_is_running(ctx.oxd_id, "oxd")
ctx.oxd_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"80/tcp\") 0).HostPort}}' ", ctx.oxd_id)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.oxd_port)
end
_M.opa = function()
local image = "openpolicyagent/opa:0.10.5"
local ctx = _G.ctx
ctx.opa_id = stdout("docker run -p 8181 -d ",
" --network=", ctx.network_name,
" --net-alias=opa ",
image,
" run --server "
)
check_container_is_running(ctx.opa_id, "opa")
ctx.opa_port =
stdout("docker inspect --format='{{(index (index .NetworkSettings.Ports \"8181/tcp\") 0).HostPort}}' ", ctx.opa_id)
local res, err = sh_ex("/opt/wait-for-http-ready.sh ", "127.0.0.1:", ctx.opa_port)
end
_M.configure_metrics_plugin = function(plugin_config)
local payload = {
name = "gluu-metrics",
config = plugin_config,
}
local payload_json = JSON:encode(payload)
print"enable metrics plugin globally"
local res, err = sh_ex([[
curl -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
end
_M.configure_ip_restrict_plugin = function(create_service_response, plugin_config)
local payload = {
name = "ip-restriction",
config = plugin_config,
service = { id = create_service_response.id},
}
local payload_json = JSON:encode(payload)
print"enable ip restriction plugin for the Service"
local res, err = sh_ex([[
curl --fail -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
return JSON:decode(res)
end
_M.setup_postgress = function(finally, model)
_G.ctx = {}
local ctx = _G.ctx
ctx.finalizeres = {}
ctx.host_git_root = host_git_root
ctx.print_logs = true
finally(function()
if ctx.print_logs then
if ctx.kong_id then
sh("docker logs ", ctx.kong_id, " || true") -- don't fail
end
if ctx.oxd_id then
sh("docker logs ", ctx.oxd_id, " || true") -- don't fail
end
end
local finalizeres = ctx.finalizeres
-- call finalizers in revers order
for i = #finalizeres, 1, -1 do
xpcall(finalizeres[i], debug.traceback)
end
end)
_M.docker_unique_network()
_M.kong_postgress()
_M.backend()
if model then
_M.oxd_mock(model)
end
end
_M.configure_service_route = function(service_name, service, route)
service_name = service_name or "demo-service"
service = service or "backend"
route = route or "backend.com"
print"create a Sevice"
local res, err = sh_until_ok(10,
[[curl --fail -sS -X POST --url http://localhost:]],
ctx.kong_admin_port, [[/services/ --header 'content-type: application/json' --data '{"name":"]],service_name,[[","url":"http://]],
service, [["}']]
)
local create_service_response = JSON:decode(res)
print"create a Route"
local res, err = sh_until_ok(10,
[[curl --fail -i -sS -X POST --url http://localhost:]],
ctx.kong_admin_port, [[/services/]], service_name, [[/routes --data 'hosts[]=]], route, [[']]
)
return create_service_response
end
_M.setup_db_less = function(finally, model, create_cookie_tmp_filename)
_G.ctx = {}
local ctx = _G.ctx
ctx.finalizeres = {}
ctx.host_git_root = host_git_root
if create_cookie_tmp_filename then
ctx.cookie_tmp_filename = pl_tmpname()
end
ctx.print_logs = true
finally(function()
if ctx.print_logs then
if ctx.kong_id then
sh("docker logs ", ctx.kong_id, " || true") -- don't fail
end
if ctx.kong_id2 then
sh("docker logs ", ctx.kong_id2, " || true") -- don't fail
end
if ctx.oxd_id then
sh("docker logs ", ctx.oxd_id, " || true") -- don't fail
end
end
local finalizeres = ctx.finalizeres
-- call finalizers in revers order
for i = #finalizeres, 1, -1 do
xpcall(finalizeres[i], debug.traceback)
end
if create_cookie_tmp_filename then
pl_file.delete(ctx.cookie_tmp_filename)
end
end)
_M.docker_unique_network()
if model then
_M.oxd_mock(model)
end
_M.backend()
end
_M.register_site = function()
local register_site = {
scope = { "openid", "uma_protection" },
op_host = "just_stub",
authorization_redirect_uri = "https://client.example.com/cb",
client_name = "demo plugin",
grant_types = { "client_credentials" }
}
local register_site_json = JSON:encode(register_site)
local res, err = sh_ex(
[[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/register-site --header 'Content-Type: application/json' --data ']],
register_site_json, [[']]
)
local register_site_response = JSON:decode(res)
return register_site_response
end
_M.register_site_get_client_token = function()
local register_site_response = _M.register_site()
local get_client_token = {
op_host = "just_stub",
client_id = register_site_response.client_id,
client_secret = register_site_response.client_secret,
}
local get_client_token_json = JSON:encode(get_client_token)
local res, err = sh_ex(
[[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/get-client-token --header 'Content-Type: application/json' --data ']],
get_client_token_json, [[']]
)
local response = JSON:decode(res)
return register_site_response, response.access_token
end
_M.configure_oauth_auth_plugin = function(create_service_response, plugin_config)
local register_site = {
scope = { "openid", "uma_protection" },
op_host = "just_stub",
authorization_redirect_uri = "https://client.example.com/cb",
client_name = "demo plugin",
grant_types = { "client_credentials" }
}
local register_site_json = JSON:encode(register_site)
local res, err = sh_ex([[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/register-site --header 'Content-Type: application/json' --data ']],
register_site_json, [[']])
local register_site_response = JSON:decode(res)
local get_client_token = {
op_host = "just_stub",
client_id = register_site_response.client_id,
client_secret = register_site_response.client_secret,
}
local get_client_token_json = JSON:encode(get_client_token)
local res, err = sh_ex([[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/get-client-token --header 'Content-Type: application/json' --data ']],
get_client_token_json, [[']])
local response = JSON:decode(res)
plugin_config.op_url = "http://stub"
plugin_config.oxd_url = "http://oxd-mock"
plugin_config.client_id = register_site_response.client_id
plugin_config.client_secret = register_site_response.client_secret
plugin_config.oxd_id = register_site_response.oxd_id
local payload = {
name = "gluu-oauth-auth",
config = plugin_config,
service = { id = create_service_response.id },
}
local payload_json = JSON:encode(payload)
print "enable plugin for the Service"
local res, err = sh_ex([[
curl -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']])
return register_site_response, response.access_token
end
_M.configure_oauth_pep_plugin = function(register_site_response, create_service_response, plugin_config, disableFail)
if plugin_config.oauth_scope_expression then
plugin_config.oauth_scope_expression = JSON:encode(plugin_config.oauth_scope_expression)
end
plugin_config.op_url = "http://stub"
plugin_config.oxd_url = "http://oxd-mock"
plugin_config.client_id = register_site_response.client_id
plugin_config.client_secret = register_site_response.client_secret
plugin_config.oxd_id = register_site_response.oxd_id
local payload = {
name = "gluu-oauth-pep",
config = plugin_config,
service = { id = create_service_response.id},
}
local payload_json = JSON:encode(payload)
print"enable plugin for the Service"
local res, err = sh_ex([[
curl ]], (disableFail and "" or "--fail") ,[[ -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
return res, err
end
_M.configure_uma_auth_plugin = function(create_service_response, plugin_config)
local register_site = {
scope = { "openid", "uma_protection" },
op_host = "just_stub",
authorization_redirect_uri = "https://client.example.com/cb",
client_name = "demo plugin",
grant_types = { "client_credentials" }
}
local register_site_json = JSON:encode(register_site)
local res, err = sh_ex(
[[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/register-site --header 'Content-Type: application/json' --data ']],
register_site_json, [[']]
)
local register_site_response = JSON:decode(res)
local get_client_token = {
op_host = "just_stub",
client_id = register_site_response.client_id,
client_secret = register_site_response.client_secret,
}
local get_client_token_json = JSON:encode(get_client_token)
local res, err = sh_ex(
[[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/get-client-token --header 'Content-Type: application/json' --data ']],
get_client_token_json, [[']]
)
local response = JSON:decode(res)
-- configure gluu-uma-auth
plugin_config.op_url = "http://stub"
plugin_config.oxd_url = "http://oxd-mock"
plugin_config.client_id = register_site_response.client_id
plugin_config.client_secret = register_site_response.client_secret
plugin_config.oxd_id = register_site_response.oxd_id
local payload = {
name = "gluu-uma-auth",
config = plugin_config,
service = { id = create_service_response.id},
}
local payload_json = JSON:encode(payload)
print"enable plugin for the Service"
local res, err = sh_ex([[
curl -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
return register_site_response, response.access_token
end
_M.configure_uma_pep_plugin = function(register_site_response, create_service_response, plugin_config, consumer_id)
if plugin_config.uma_scope_expression then
plugin_config.uma_scope_expression = JSON:encode(plugin_config.uma_scope_expression)
end
plugin_config.op_url = "http://stub"
plugin_config.oxd_url = "http://oxd-mock"
plugin_config.client_id = register_site_response.client_id
plugin_config.client_secret = register_site_response.client_secret
plugin_config.oxd_id = register_site_response.oxd_id
local payload = {
name = "gluu-uma-pep",
config = plugin_config,
service = { id = create_service_response.id},
}
if consumer_id then
payload.consumer_id = consumer_id
end
local payload_json = JSON:encode(payload)
print"enable plugin for the Service"
local res, err = sh_ex([[
curl --fail -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
end
_M.configure_openid_connect_plugin = function(create_service_response, plugin_config)
if plugin_config.required_acrs_expression then
plugin_config.required_acrs_expression = JSON:encode(plugin_config.required_acrs_expression)
end
local register_site = {
scope = { "openid", "uma_protection" },
op_host = "just_stub",
authorization_redirect_uri = "https://client.example.com/cb",
client_name = "demo plugin",
grant_types = { "client_credentials" }
}
local register_site_json = JSON:encode(register_site)
local res, err = sh_ex(
[[curl --fail -v -sS -X POST --url http://localhost:]], ctx.oxd_port,
[[/register-site --header 'Content-Type: application/json' --data ']],
register_site_json, [[']]
)
local register_site_response = JSON:decode(res)
plugin_config.op_url = "http://stub"
plugin_config.oxd_url = "http://oxd-mock"
plugin_config.client_id = register_site_response.client_id
plugin_config.client_secret = register_site_response.client_secret
plugin_config.oxd_id = register_site_response.oxd_id
local payload = {
name = "gluu-openid-connect",
config = plugin_config,
service = { id = create_service_response.id},
}
local payload_json = JSON:encode(payload)
print"enable plugin for the Service"
local res, err = sh_ex([[
curl -v -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/ ]],
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
local plugin_response = JSON:decode(res)
return register_site_response, plugin_response
end
_M.update_openid_connect_required_acrs_expression = function(plugin_id, required_acrs_expression)
local required_acrs_expression_json = JSON:encode(required_acrs_expression)
local payload = {
config = {
required_acrs_expression = required_acrs_expression_json
},
}
local payload_json = JSON:encode(payload)
print"update plugin"
local res, err = sh_ex([[
curl --fail -v -i -sS -X PATCH --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/]], plugin_id,
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload_json, [[']]
)
end
_M.unset_openid_connect_required_acrs_expression = function(plugin_id)
local payload = [[{
"config": { "required_acrs_expression" : null }
}]]
print"unset_required_acrs_expression"
local res, err = sh_ex([[
curl --fail -v -i -sS -X PATCH --url http://localhost:]], ctx.kong_admin_port,
[[/plugins/]], plugin_id,
[[ --header 'content-type: application/json;charset=UTF-8' --data ']], payload, [[']]
)
end
_M.db_less_reconfigure = function(config)
local payload = JSON:encode(config)
local res, err = sh_ex([[
curl --fail -v -i -sS -X POST --url http://localhost:]], ctx.kong_admin_port,
[[/config --header 'content-type: application/json;charset=UTF-8' --data ']], payload, [[']]
)
sleep(2)
end
return _M
|
-- multiDemo.lua
--
-- Demonstrates how to use luadep to define a dependency that accepts multiple modules.
local module = require("module")
local container = require("container")
local recipeBook = module({})
:setName("VanillaRecipeBook")
:setVersion("1.0.0-beta")
:isA("RecipeBook")
:dependsOn("Recipe", "0..*")
local pancakes = module({
Name = "Tasty pancakes"
})
:setName("VanillaPancakeRecipe")
:setVersion("1.0.0-beta")
:isA("Recipe")
local cheesecake = module({
Name = "Fresh cheesecake"
})
:setName("henkoglobin-CheesecakeRecipe")
:setVersion("0.1.0")
:isA("Recipe")
local myContainer = container()
-- Feel free to try out the capabilities of luadep by
-- commenting/uncommenting the following lines
myContainer:collect(recipeBook)
myContainer:collect(pancakes)
myContainer:collect(cheesecake)
local ok, missing = myContainer:validate()
if not ok then
print("Missing (module, interface):")
for moduleName, interface in pairs(missing) do
print(moduleName, ", ", interface)
end
end
local myRecipes = myContainer:get("RecipeBook")
for _, recipe in pairs(myRecipes.Recipe) do
print(("I know how to cook %s"):format(recipe.Name))
end
|
-------------------------------------------------------------------------------
--
-- The comment extraction example given in doc/grammar.html. For those of you
-- who haven't read it, the code and comments are available below.
--
-- Authors: Humberto Anjos and Francisco Sant'Anna
--
-- $Id: comment-extraction.lua,v 1.3 2007/12/07 14:23:56 hanjos Exp $
--
-------------------------------------------------------------------------------
-- some imports to get things started.
local lpeg = require 'lpeg'
require "leg" -- check if available (and preload leg submodules)
local parser = require 'leg.parser'
local grammar = require 'leg.grammar'
-- some aliasing
local P, V = lpeg.P, lpeg.V
-- argument capturing
local args = { ... }
--
-- Let's consider the problem of documenting a Lua module. In this case, comments
-- must be captured before every function declaration when in the outermost scope.
--
-- the code to parse
local subject = args[1] or [=[
-- Calculates the sum a+b.
-- An extra line.
function sum (a, b)
-- code
end
-- a variable assignment is not a "proper" declaration for an
-- exported function
f1 = function ()
-- code
end
while true do
-- this function is not in the outermost scope
function aux() end
end
function something:other(a, ...)
-- a global function without comments
return a, ... -- won't appear in the result
end
]=]
-- In the code above we want only to document sum and something:other, as
-- f1 isn't properly (by our standards) declared and aux is not in the
-- outermost scope (although it is still a global function).
--
-- Let's define some patterns to simplify our job:
-- spacing rule
local S = parser.SPACE ^ 0
-- matches any Lua statement, no captures
Stat = P( parser.apply(V'Stat', nil) )
-- some interesting captures bundled up in a table. Note that the table keys
-- match the grammar rules we want to add captures to. Any rules not in the
-- `rules` table below will come from parser.rules .
captures = {
[1] = function (...) -- the initial rule
return '<function>'..table.concat{...}..'</function>'
end,
GlobalFunction = function (name, parlist) -- global function declaration
return '<name>'..name..'</name><parlist>'..(parlist or '')..'</parlist>'
end,
FuncName = grammar.C, -- capture the raw text
ParList = grammar.C, -- capture the raw text
COMMENT = parser.comment2text, -- extract comment trappings
}
-- the rules table
rules = {
[1] = ((V'COMMENT' *S) ^ 0) *S* V'GlobalFunction', -- new initial rule
COMMENT = parser.COMMENT, -- just to add COMMENT's capture to the capture table
}
-- building the new grammar and adding the captures. This pattern will match
-- any global function optionally preceded by comments, and return a string
-- in the following format:
--
-- <function>comments<name>name</name><parlist>parameter list</parlist></function>
commentedFunc = P( grammar.apply(parser.rules, rules, captures) )
-- finally, this pattern matches all commented global functions, Stats
-- or any other Lua tokens and packages the results in a table. This is done
-- to capture only global function declarations in the global scope.
patt = (commentedFunc + Stat + parser.ANY)^0 / function(...)
return table.concat({...}, '\n\n') -- some line breaks for easier reading
end
-- now match subject
print('subject:', '\n'..subject)
print('result:', '\n'..patt:match(subject))
|
ENT.Type = "ai";
ENT.Base = "base_ai"; |
--- Injects a loverocks-compatible module loader into your game.
-- See http://github.com/Alloyed/loverocks for details
-- (c) Kyle McLamb, 2016 <alloyed@tfwno.gf>, MIT License.
<%- rocks_warning %>
-- |version: <%- loverocks_version %>|
local rocks_tree = (...)
local rocks = {}
rocks.paths = {
rocks_tree .. "/share/lua/5.1/?.lua",
rocks_tree .. "/share/lua/5.1/?/init.lua",
}
rocks.cpaths = {
rocks_tree .. "/lib/lua/5.1/?"
}
-- love API shims
local function get_os()
if love.system and love.system.getOS then -- >= 0.9.0
return love.system.getOS()
elseif love._os then -- < 0.9.0
return love._os
else
-- either love.system wasn't loaded or something else happened
return nil
end
end
local function file_exists(name)
if love.filesystem.getInfo then -- >= 11
return love.filesystem.getInfo(name, 'file') ~= nil
else -- < 11
return love.filesystem.isFile(name)
end
end
local function path_exists(name)
if love.filesystem.getInfo then -- >= 11
return love.filesystem.getInfo(name) ~= nil
else -- < 11
return love.filesystem.exists(name)
end
end
---
-- Loads loverocks modules.
function rocks.loader(modname)
local modpath = modname:gsub('%.', '/')
for _, elem in ipairs(rocks.paths) do
elem = elem:gsub('%?', modpath)
if file_exists(elem) then
return love.filesystem.load(elem)
end
end
return "\n\tno module '" .. modname .. "' in LOVERocks path."
end
local function can_open(fname)
local f, err = io.open(fname, 'r')
if f == nil then
return false
end
f:close()
return true
end
local function c_loader(modname, fn_name)
-- turn periods into underscores, and remove a hyphen-prefix.
-- The rules for this are here:
-- https://www.lua.org/manual/5.1/manual.html#pdf-package.loaders
-- I might have the details wrong, PRs welcome
fn_name = fn_name:gsub("%.", "_"):gsub("^[^-]*-", "")
local os = get_os()
if not os then
return "\n\tCannot load native LOVERocks modules, OS not found."
end
local ext = os == 'Windows' and ".dll" or ".so"
local file = modname:gsub("%.", "/") .. ext
for _, elem in ipairs(rocks.cpaths) do
elem = elem:gsub('%?', file)
local base = nil
if love.filesystem.isFused() then
base = love.filesystem.getSourceBaseDirectory()
if can_open(base .. "/" ..elem) == false then
base = nil -- actually, file not found
end
elseif path_exists(elem) then
base = love.filesystem.getRealDirectory(elem)
end
if base then
local path = base .. "/" .. elem
local lib, err1 = package.loadlib(path, "loveopen_"..fn_name)
if lib then return lib end
local err2
lib, err2 = package.loadlib(path, "luaopen_"..fn_name)
if lib then return lib end
if err1 == err2 then
return "\n\t"..err1
else
return "\n\t"..err1.."\n\t"..err2
end
end
end
return "\n\tno library '" .. file .. "' in LOVERocks path."
end
---
-- Loads native loverocks libraries. In fused mode, these should be placed in
-- the same directory as the game binary. In non-fused(source) mode these can
-- either be placed in the game's saveDirectory or within the game's source if
-- it is run from a folder. Notably, there is no way to load a library that
-- is packed into a love file.
function rocks.c_1_loader(modname)
return c_loader(modname, modname)
end
---
-- Loads native libraries using the "all-in-one" technique supported by vanilla
-- lua and used by libraries luasec to compile several modules into a
-- single library. It shares the same path rules as `rocks.c_1_loader`.
function rocks.c_all_loader(modname)
local base_mod = modname:match("^.+%.")
if base_mod then
return c_loader(base_mod, modname)
end
end
---
-- Installs the LOVERocks package loader if it's not already installed.
-- @param use_external_deps Set to a truthy value if you would like to continue
-- using system-level dependencies in your project.
function rocks.inject(use_external_deps)
if package._loverocks then return rocks end
table.insert(package.loaders, rocks.loader)
table.insert(package.loaders, rocks.c_1_loader)
table.insert(package.loaders, rocks.c_all_loader)
package._loverocks = true
if not use_external_deps then
-- It would be nice to just yoink the native loaders out entirely
package.path = ""
package.cpath = ""
end
return rocks
end
---
-- Attempts to `require` the given module, but will suggest that the user try
-- manually installing dependencies if they aren't found. This can be useful
-- for source distribution. Behaves like `require` when in fused mode.
function rocks.require(modname)
if love.filesystem.isFused() then return require(modname) end
local ok, err_or_mod = pcall(require, modname)
if not ok then
error(string.format([[
Dependency not found: %s
If you downloaded a source package (a.k.a a ".love" file),
you can try installing the dependencies using LOVERocks:
$ loverocks --game <my_game.love> deps
More info at <https://github.com/Alloyed/loverocks>
%s
]], modname, err_or_mod))
end
return err_or_mod
end
return setmetatable(rocks, {__call = rocks.inject})
|
-- This script demonstrates button remapping. The player character in this
-- game can do four things: jump, shoot, crouch, and run. By pressing start,
-- the player is taken to a screen where they can assign which face buttons go
-- with which action.
-- This example assumes controllers with XINPUT aka XBOX 360 button mappings.
------------------------------------------------------------------------------
-- constants
------------------------------------------------------------------------------
--game modes
MODE_PLAY = 0
MODE_INPUT_CONFIG = 1
--player states
STATE_WALKING = 0
STATE_RUNNING = 1
STATE_CROUCHING = 2
STATE_JUMPING = 3
--bullet tweaks
BULLET_SCALE = 4.0
BULLET_SPEED = 10
SHOTS_PER_SECOND = 8
MS_PER_SHOT = 1000 / SHOTS_PER_SECOND
--movement tweaks
CROUCH_SPEED_MULTIPLIER = 0.1
RUN_SPEED_MULTIPLIER = 3.0
--hardware constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
NUM_CONFIGURABLE_BUTTONS = 4
START_BUTTON_ID = 7
------------------------------------------------------------------------------
-- global data
------------------------------------------------------------------------------
--ux management state
gameMode = MODE_PLAY
startWasPressed = false
selectionChanged = false
buttonChanged = false
buttonConfigSelectedOption = 0
--container for images
images = {}
--fire management state
fireDirection = 1
fireTimer = 0
bullets = {}
--action request state
requests = {}
requests.fire = false
requests.run = false
requests.crouch = false
requests.jump = false
------------------------------------------------------------------------------
-- commands
------------------------------------------------------------------------------
doFire = {}
function doFire.execute()
requests.fire = true
end
doRun = {}
function doRun.execute()
requests.run = true
end
doCrouch = {}
function doCrouch.execute()
requests.crouch = true
end
doJump = {}
function doJump.execute()
requests.jump = true
end
commands = {}
commands[0] = doJump
commands[1] = doFire
commands[2] = doCrouch
commands[3] = doRun
------------------------------------------------------------------------------
-- helper functions
------------------------------------------------------------------------------
function ReadPlayerInput()
for i = 0, NUM_CONFIGURABLE_BUTTONS - 1 do
if ReadControllerButton(0, i) then
commands[i].execute()
end
end
end
function FindButton(command)
for i = 0, NUM_CONFIGURABLE_BUTTONS - 1 do
if commands[i] == command then
return i
end
end
--provides visual cue in button config
--menu that a command is not mapped.
return -1
end
--toggle between game and config menu when START button pressed.
--(but ignore multiple requests to toggle until START button has been released.)
function UpdatePause()
local startPressed = ReadControllerButton(0, START_BUTTON_ID)
if not startWasPressed and startPressed then
if gameMode == MODE_PLAY then gameMode = MODE_INPUT_CONFIG
elseif gameMode == MODE_INPUT_CONFIG then gameMode = MODE_PLAY end
end
startWasPressed = startPressed
end
--Load fonts and images used in this example.
function LoadAssets()
font = LoadFont("fonts/8_bit_pusab.ttf", 16)
bigFont = LoadFont("fonts/8_bit_pusab.ttf", 64)
images.idle = LoadImage("images/tiles32/idle.png")
images.left = LoadImage("images/tiles32/left.png")
images.right = LoadImage("images/tiles32/right.png")
images.crouch = LoadImage("images/tiles32/crouch.png")
images.ground = LoadImage("images/tiles32/ground.png")
images.fireball = LoadImage("images/tiles32/fireball.png")
end
--add a new bullet to the world, originating from the player.
function Fire()
fireTimer = fireTimer + MS_PER_SHOT
bullet = {}
bullet.image = images.fireball
--adjust for size of player and size of bullet
bullet.x = player.x + TILE_SIZE / 2 - GetImageWidth(bullet.image) / 2
bullet.y = player.y + TILE_SIZE / 4 - GetImageHeight(bullet.image) / 2
bullet.xVel = BULLET_SPEED * fireDirection
bullets[#bullets + 1] = bullet
end
function UpdateBullets()
if fireTimer > 0 then
fireTimer = fireTimer - GetFrameTime()
if fireTimer < 0 then
fireTimer = 0
end
end
--move all bullets, and destroy bullets that have left the screen.
for i = #bullets, 1, -1 do
bullets[i].x = bullets[i].x + bullets[i].xVel
local w = GetImageWidth(bullets[i].image)
local h = GetImageHeight(bullets[i].image)
if bullets[i].x > SCREEN_WIDTH + w
or bullets[i].x < -w
or bullets[i].y > SCREEN_HEIGHT + h
or bullets[i].y < -h then
table.remove(bullets, i)
end
end
end
function InitPlayer()
player = {}
player.state = STATE_WALKING
player.x = SCREEN_WIDTH / 2 - TILE_SIZE / 2
player.y = GROUND_HEIGHT - TILE_SIZE
player.xVel = 0
player.yVel = 0
player.xAcc = 0
player.yAcc = 0
player.speed = 1
player.maxSpeed = 8
player.drag = 0.85
player.jumpImpulse = 25
player.gravity = 0.05
end
--only switch fire directions if player moves
function UpdatePlayerFireDirection()
if math.abs(player.xVel) > 0 then
if player.xVel < 0 then
fireDirection = -1
else
fireDirection = 1
end
end
end
--handles moving and jumping for the player
function UpdatePlayerMovement()
if requests.jump and player.state ~= STATE_JUMPING then
player.yVel = -player.jumpImpulse
player.state = STATE_JUMPING
end
local axis0 = GetInputX(0)
if math.abs(axis0) > 0 then
player.xAcc = player.speed
if axis0 < 0 then
player.xAcc = -player.xAcc
end
if player.state == STATE_RUNNING then
player.xAcc = player.xAcc * RUN_SPEED_MULTIPLIER
end
else
player.xAcc = 0
end
if player.state == STATE_JUMPING then
player.yAcc = player.yAcc - player.gravity
end
player.xVel = player.xVel + player.xAcc
player.yVel = player.yVel - player.yAcc
-- remove very small x velocities
if math.abs(player.xVel) < 0.2 then
player.xVel = 0
end
--update player's position based on their velocity
player.x = player.x + player.xVel
player.y = player.y + player.yVel
-- adjust speed for crouching and running players.
local maxSpeed = player.maxSpeed
if player.state == STATE_CROUCHING then
maxSpeed = maxSpeed * CROUCH_SPEED_MULTIPLIER
elseif player.state == STATE_RUNNING then
maxSpeed = maxSpeed * RUN_SPEED_MULTIPLIER
end
-- clamp max x velocity
if player.xVel > maxSpeed then
player.xVel = maxSpeed
elseif player.xVel < -maxSpeed then
player.xVel = -maxSpeed
end
-- apply drag
player.xVel = player.xVel * player.drag
-- lock player to world
if player.x < 0 then
player.x = 0
player.xVel = 0
end
if player.x > SCREEN_WIDTH - TILE_SIZE then
player.x = SCREEN_WIDTH - TILE_SIZE
player.xVel = 0
end
--check for jumping players that have landed on the ground.
if player.y > GROUND_HEIGHT - TILE_SIZE then
player.y = GROUND_HEIGHT - TILE_SIZE
player.yVel = 0
player.yAcc = 0
player.state = STATE_WALKING
end
end
--update running and crouching
function UpdateLocomotionState()
if player.state ~= STATE_JUMPING and requests.run then
player.state = STATE_RUNNING
end
if player.state == STATE_RUNNING and not requests.run then
player.state = STATE_WALKING
end
if player.state ~= STATE_JUMPING and requests.crouch then
player.state = STATE_CROUCHING
end
if player.state == STATE_CROUCHING and not requests.crouch then
player.state = STATE_WALKING
end
end
--reset all requests. Player input may
--set some of these to true during the next Update()
function ClearActionRequests()
requests.fire = false
requests.run = false
requests.crouch = false
requests.jump = false
end
function UpdatePlayer()
ReadPlayerInput()
UpdatePlayerFireDirection()
UpdatePlayerMovement()
UpdateLocomotionState()
--updating firing
if fireTimer == 0 and requests.fire then
Fire()
end
ClearActionRequests()
end
function DrawHud()
if not IsControllerAttached(0) then
DrawText("Please attach a controller.", 16, 16, font, 255, 255, 255)
else
DrawText("Press start to configure controls.", 16, 16, font, 255, 255, 255)
end
end
function DrawBullets()
for i = 1, #bullets do
DrawImage(bullets[i].image, bullets[i].x, bullets[i].y, 0, BULLET_SCALE)
end
end
function DrawPlayer()
local playerImage = nil
if player.state == STATE_CROUCHING then
playerImage = images.crouch
elseif player.state == STATE_RUNNING then
if player.xVel == 0 then
playerImage = images.idle
elseif player.xVel > 0 then
playerImage = images.right
else
playerImage = images.left
end
else
playerImage = images.idle
end
DrawImage(playerImage, player.x, player.y)
end
function DrawGround()
local x = 0
while x < SCREEN_WIDTH do
DrawImage(images.ground, x, GROUND_HEIGHT)
x = x + TILE_SIZE
end
end
--handles input for the button config menu.
--user can select the action (fire, jump, etc.) by pressing up or down.
--pressing a face button (or whatever is mapped to 0-N on the controller) will
-- assign the selected action to that button.
function UpdateButtonMapper()
--change selected action in menu if user presses up or down
local inputY = GetInputY(0)
if not selectionChanged then
if inputY < 0 then
buttonConfigSelectedOption = buttonConfigSelectedOption - 1
elseif inputY > 0 then
buttonConfigSelectedOption = buttonConfigSelectedOption + 1
end
--wrap list
if buttonConfigSelectedOption >= NUM_CONFIGURABLE_BUTTONS then
buttonConfigSelectedOption = 0
elseif buttonConfigSelectedOption < 0 then
buttonConfigSelectedOption = NUM_CONFIGURABLE_BUTTONS - 1
end
end
selectionChanged = math.abs(inputY) > 0
-- if user presses a (debounced) face button, assign the
-- currently selected action to that button.
if not buttonChanged then
for i = 0, 3 do
if ReadControllerButton(0, i) then
local handler = nil
--this happens to be the order of the actions in the menu
if buttonConfigSelectedOption == 0 then handler = doFire
elseif buttonConfigSelectedOption == 1 then handler = doJump
elseif buttonConfigSelectedOption == 2 then handler = doRun
elseif buttonConfigSelectedOption == 3 then handler = doCrouch end
local oldButton = FindButton(handler)
local oldHandler = commands[i]
--early out if button is trying to swap with itself.
if i == oldButton then break end
--swap button handlers
commands[i] = handler
commands[oldButton] = oldHandler
buttonChanged = true
end
end
else --must release all face buttons before user can reassign again
local anyButtonPressed = false
for i = 0, NUM_CONFIGURABLE_BUTTONS - 1 do
if ReadControllerButton(0, i) then
anyButtonPressed = true
end
end
if not anyButtonPressed then
buttonChanged = false
end
end
end
function DrawButtonMapper(x, y, leading)
--instructions
DrawText("Press a face button to assign the selected command.", 16, 16, font, 127, 127, 127)
DrawText("Press Start to exit.", 16, 48, font, 127, 127, 127)
--button mapper
DrawText("Fire: " .. FindButton(doFire), x, y + leading * 0, bigFont, 255, 255, 255)
DrawText("Jump: " .. FindButton(doJump), x, y + leading * 1, bigFont, 255, 255, 255)
DrawText("Run: " .. FindButton(doRun), x, y + leading * 2, bigFont, 255, 255, 255)
DrawText("Crouch: " .. FindButton(doCrouch), x, y + leading * 3, bigFont, 255, 255, 255)
--highlight selected option
local rectX = x
local rectY = y + leading * buttonConfigSelectedOption
local rectW = 530
local rectH = 120
SetDrawColor(255, 255, 128, 255)
DrawRect(rectX, rectY, rectW, rectH)
SetDrawColor(255, 255, 64, 64)
FillRect(rectX, rectY, rectW, rectH)
end
------------------------------------------------------------------------------
-- core functions
------------------------------------------------------------------------------
function Start()
CreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT)
SetWindowTitle("Button Remapping Demo")
LoadAssets()
TILE_SIZE = GetImageHeight(images.ground)
GROUND_HEIGHT = SCREEN_HEIGHT - TILE_SIZE
InitPlayer()
end
function Update()
UpdatePause()
if gameMode == MODE_PLAY then
UpdateBullets()
UpdatePlayer()
elseif gameMode == MODE_INPUT_CONFIG then
UpdateButtonMapper()
end
end
function Draw()
if gameMode == MODE_PLAY then
ClearScreen(68, 136, 204)
DrawHud()
DrawBullets()
DrawPlayer()
DrawGround()
elseif gameMode == MODE_INPUT_CONFIG then
ClearScreen(0, 0, 0)
DrawButtonMapper(80, 96, 120)
end
end |
---------------------------------------------------------------------------
-- @author Uli Schlachter
-- @copyright 2010 Uli Schlachter
-- @popupmod wibox
---------------------------------------------------------------------------
local capi = {
drawin = drawin,
root = root,
awesome = awesome,
screen = screen
}
local setmetatable = setmetatable
local pairs = pairs
local type = type
local object = require("gears.object")
local grect = require("gears.geometry").rectangle
local beautiful = require("beautiful")
local base = require("wibox.widget.base")
local cairo = require("lgi").cairo
--- This provides widget box windows. Every wibox can also be used as if it were
-- a drawin. All drawin functions and properties are also available on wiboxes!
-- wibox
local wibox = { mt = {}, object = {} }
wibox.layout = require("wibox.layout")
wibox.container = require("wibox.container")
wibox.widget = require("wibox.widget")
wibox.drawable = require("wibox.drawable")
wibox.hierarchy = require("wibox.hierarchy")
local force_forward = {
shape_bounding = true,
shape_clip = true,
shape_input = true,
}
----- Border width.
--
-- @baseclass wibox
-- @property border_width
-- @param integer
-- @propemits false false
--- Border color.
--
-- Please note that this property only support string based 24 bit or 32 bit
-- colors:
--
-- Red Blue
-- _| _|
-- #FF00FF
-- T‾
-- Green
--
--
-- Red Blue
-- _| _|
-- #FF00FF00
-- T‾ ‾T
-- Green Alpha
--
-- @baseclass wibox
-- @property border_color
-- @param string
-- @propemits false false
--- On top of other windows.
--
-- @baseclass wibox
-- @property ontop
-- @param boolean
-- @propemits false false
--- The mouse cursor.
--
-- @baseclass wibox
-- @property cursor
-- @param string
-- @see mouse
-- @propemits false false
--- Visibility.
--
-- @baseclass wibox
-- @property visible
-- @param boolean
-- @propemits false false
--- The opacity of the wibox, between 0 and 1.
--
-- @baseclass wibox
-- @property opacity
-- @tparam number opacity (between 0 and 1)
-- @propemits false false
--- The window type (desktop, normal, dock, ...).
--
-- @baseclass wibox
-- @property type
-- @param string
-- @see client.type
-- @propemits false false
--- The x coordinates.
--
-- @baseclass wibox
-- @property x
-- @param integer
-- @propemits false false
--- The y coordinates.
--
-- @baseclass wibox
-- @property y
-- @param integer
-- @propemits false false
--- The width of the wibox.
--
-- @baseclass wibox
-- @property width
-- @param width
-- @propemits false false
--- The height of the wibox.
--
-- @baseclass wibox
-- @property height
-- @param height
-- @propemits false false
--- The wibox screen.
--
-- @baseclass wibox
-- @property screen
-- @param screen
-- @propemits true false
--- The wibox's `drawable`.
--
-- @baseclass wibox
-- @property drawable
-- @tparam drawable drawable
-- @propemits false false
--- The widget that the `wibox` displays.
-- @baseclass wibox
-- @property widget
-- @param widget
-- @propemits true false
--- The X window id.
--
-- @baseclass wibox
-- @property window
-- @param string
-- @see client.window
-- @propemits false false
--- The wibox's bounding shape as a (native) cairo surface.
--
-- If you want to set a shape, let say some rounded corners, use
-- the `shape` property rather than this. If you want something
-- very complex, for example, holes, then use this.
--
-- @baseclass wibox
-- @property shape_bounding
-- @param surface._native
-- @propemits false false
-- @see shape
--- The wibox's clip shape as a (native) cairo surface.
--
-- The clip shape is the shape of the window *content* rather
-- than the outer window shape.
--
-- @baseclass wibox
-- @property shape_clip
-- @param surface._native
-- @propemits false false
-- @see shape
--- The wibox's input shape as a (native) cairo surface.
--
-- The input shape allows to disable clicks and mouse events
-- on part of the window. This is how `input_passthrough` is
-- implemented.
--
-- @baseclass wibox
-- @property shape_input
-- @param surface._native
-- @propemits false false
-- @see input_passthrough
--- The wibar's shape.
--
-- @baseclass wibox
-- @property shape
-- @tparam gears.shape shape
-- @propemits true false
-- @see gears.shape
--- Forward the inputs to the client below the wibox.
--
-- This replace the `shape_input` mask with an empty area. All mouse and
-- keyboard events are sent to the object (such as a client) positioned below
-- this wibox. When used alongside compositing, it allows, for example, to have
-- a subtle transparent wibox on top a fullscreen client to display important
-- data such as a low battery warning.
--
-- @baseclass wibox
-- @property input_passthrough
-- @param[opt=false] boolean
-- @see shape_input
-- @propemits true false
--- Get or set mouse buttons bindings to a wibox.
--
-- @baseclass wibox
-- @property buttons
-- @param buttons_table A table of buttons objects, or nothing.
-- @propemits false false
--- Get or set wibox geometry. That's the same as accessing or setting the x,
-- y, width or height properties of a wibox.
--
-- @baseclass wibox
-- @param A table with coordinates to modify.
-- @return A table with wibox coordinates and geometry.
-- @method geometry
-- @emits property::geometry When the geometry change.
-- @emitstparam property::geometry table geo The geometry table.
--- Get or set wibox struts.
--
-- Struts are the area which should be reserved on each side of
-- the screen for this wibox. This is used to make bars and
-- docked displays. Note that `awful.wibar` implements all the
-- required boilerplate code to make bar. Only use this if you
-- want special type of bars (like bars not fully attached to
-- the side of the screen).
--
-- @baseclass wibox
-- @param strut A table with new strut, or nothing
-- @return The wibox strut in a table.
-- @method struts
-- @see client.struts
-- @emits property::struts
--- The default background color.
--
-- The background color can be transparent. If there is a
-- compositing manager such as compton, then it will be
-- real transparency and may include blur (provided by the
-- compositor). When there is no compositor, it will take
-- a picture of the wallpaper and blend it.
--
-- @baseclass wibox
-- @beautiful beautiful.bg_normal
-- @param color
-- @see bg
--- The default foreground (text) color.
-- @baseclass wibox
-- @beautiful beautiful.fg_normal
-- @param color
-- @see fg
--- Set a declarative widget hierarchy description.
-- See [The declarative layout system](../documentation/03-declarative-layout.md.html)
-- @param args An array containing the widgets disposition
-- @baseclass wibox
-- @method setup
--- The background of the wibox.
--
-- The background color can be transparent. If there is a
-- compositing manager such as compton, then it will be
-- real transparency and may include blur (provided by the
-- compositor). When there is no compositor, it will take
-- a picture of the wallpaper and blend it.
--
-- @baseclass wibox
-- @property bg
-- @tparam c The background to use. This must either be a cairo pattern object,
-- nil or a string that gears.color() understands.
-- @see gears.color
-- @propemits true false
-- @usebeautiful beautiful.bg_normal The default (fallback) bg color.
--- The background image of the drawable.
--
-- If `image` is a function, it will be called with `(context, cr, width, height)`
-- as arguments. Any other arguments passed to this method will be appended.
--
-- @tparam gears.suface|string|function image A background image or a function.
-- @baseclass wibox
-- @property bgimage
-- @see gears.surface
-- @propemits true false
--- The foreground (text) of the wibox.
-- @tparam color c The foreground to use. This must either be a cairo pattern object,
-- nil or a string that gears.color() understands.
-- @baseclass wibox
-- @property fg
-- @param color
-- @see gears.color
-- @propemits true false
-- @usebeautiful beautiful.fg_normal The default (fallback) fg color.
--- Find a widget by a point.
-- The wibox must have drawn itself at least once for this to work.
-- @tparam number x X coordinate of the point
-- @tparam number y Y coordinate of the point
-- @treturn table A sorted table of widgets positions. The first element is the biggest
-- container while the last is the topmost widget. The table contains *x*, *y*,
-- *width*, *height* and *widget*.
-- @baseclass wibox
-- @method find_widgets
function wibox:set_widget(widget)
local w = base.make_widget_from_value(widget)
self._drawable:set_widget(w)
self:emit_signal("property::widget", widget)
end
function wibox:get_widget()
return self._drawable.widget
end
wibox.setup = base.widget.setup
function wibox:set_bg(c)
self._drawable:set_bg(c)
self:emit_signal("property::bg", c)
end
function wibox:set_bgimage(image, ...)
self._drawable:set_bgimage(image, ...)
self:emit_signal("property::bgimage", ...)
end
function wibox:set_fg(c)
self._drawable:set_fg(c)
self:emit_signal("property::fg", c)
end
function wibox:find_widgets(x, y)
return self._drawable:find_widgets(x, y)
end
function wibox:_buttons(btns)
-- The C code uses the argument count, `nil` counts.
return btns and self.drawin:_buttons(btns) or self.drawin:_buttons()
end
--- Create a widget that reflects the current state of this wibox.
-- @treturn widget A new widget.
-- @method to_widget
function wibox:to_widget()
local bw = self.border_width or beautiful.border_width or 0
return wibox.widget {
{
self:get_widget(),
margins = bw,
widget = wibox.container.margin
},
bg = self.bg or beautiful.bg_normal or "#ffffff",
fg = self.fg or beautiful.fg_normal or "#000000",
shape_border_color = self.border_color or beautiful.border_color or "#000000",
shape_border_width = bw*2,
shape_clip = true,
shape = self._shape,
forced_width = self:geometry().width + 2*bw,
forced_height = self:geometry().height + 2*bw,
widget = wibox.container.background
}
end
--- Save a screenshot of the wibox to `path`.
-- @tparam string path The path.
-- @tparam[opt=nil] table context A widget context.
-- @method save_to_svg
function wibox:save_to_svg(path, context)
wibox.widget.draw_to_svg_file(
self:to_widget(), path, self:geometry().width, self:geometry().height, context
)
end
function wibox:_apply_shape()
local shape = self._shape
if not shape then
self.shape_bounding = nil
self.shape_clip = nil
return
end
local geo = self:geometry()
local bw = self.border_width
-- First handle the bounding shape (things including the border)
local img = cairo.ImageSurface(cairo.Format.A1, geo.width + 2*bw, geo.height + 2*bw)
local cr = cairo.Context(img)
-- We just draw the shape in its full size
shape(cr, geo.width + 2*bw, geo.height + 2*bw)
cr:set_operator(cairo.Operator.SOURCE)
cr:fill()
self.shape_bounding = img._native
img:finish()
-- Now handle the clip shape (things excluding the border)
img = cairo.ImageSurface(cairo.Format.A1, geo.width, geo.height)
cr = cairo.Context(img)
-- We give the shape the same arguments as for the bounding shape and draw
-- it in its full size (the translate is to compensate for the smaller
-- surface)
cr:translate(-bw, -bw)
shape(cr, geo.width + 2*bw, geo.height + 2*bw)
cr:set_operator(cairo.Operator.SOURCE)
cr:fill_preserve()
-- Now we remove an area of width 'bw' again around the shape (We use 2*bw
-- since half of that is on the outside and only half on the inside)
cr:set_source_rgba(0, 0, 0, 0)
cr:set_line_width(2*bw)
cr:stroke()
self.shape_clip = img._native
img:finish()
end
function wibox:set_shape(shape)
self._shape = shape
self:_apply_shape()
self:emit_signal("property::shape", shape)
end
function wibox:get_shape()
return self._shape
end
function wibox:set_input_passthrough(value)
rawset(self, "_input_passthrough", value)
if not value then
self.shape_input = nil
else
local img = cairo.ImageSurface(cairo.Format.A1, 0, 0)
self.shape_input = img._native
img:finish()
end
self:emit_signal("property::input_passthrough", value)
end
function wibox:get_input_passthrough()
return self._input_passthrough
end
function wibox:get_screen()
if self.screen_assigned and self.screen_assigned.valid then
return self.screen_assigned
else
self.screen_assigned = nil
end
local sgeos = {}
for s in capi.screen do
sgeos[s] = s.geometry
end
return grect.get_closest_by_coord(sgeos, self.x, self.y)
end
function wibox:set_screen(s)
s = capi.screen[s or 1]
if s ~= self:get_screen() then
self.x = s.geometry.x
self.y = s.geometry.y
end
-- Remember this screen so things work correctly if screens overlap and
-- (x,y) is not enough to figure out the correct screen.
self.screen_assigned = s
self._drawable:_force_screen(s)
self:emit_signal("property::screen", s)
end
function wibox:get_children_by_id(name)
--TODO v5: Move the ID management to the hierarchy.
if rawget(self, "_by_id") then
--TODO v5: Remove this, it's `if` nearly dead code, keep the `elseif`
return rawget(self, "_by_id")[name]
elseif self._drawable.widget
and self._drawable.widget._private
and self._drawable.widget._private.by_id then
return self._drawable.widget._private.by_id[name]
end
return {}
end
-- Proxy those properties to decorate their accessors with an extra flag to
-- define when they are set by the user. This allows to "manage" the value of
-- those properties internally until they are manually overridden.
for _, prop in ipairs { "border_width", "border_color", "opacity" } do
wibox["get_"..prop] = function(self)
return self["_"..prop]
end
wibox["set_"..prop] = function(self, value)
self._private["_user_"..prop] = true
self["_"..prop] = value
end
end
for _, k in ipairs{ "struts", "geometry", "get_xproperty", "set_xproperty" } do
wibox[k] = function(self, ...)
return self.drawin[k](self.drawin, ...)
end
end
object.properties._legacy_accessors(wibox.object, "buttons", "_buttons", true, function(new_btns)
return new_btns[1] and (
type(new_btns[1]) == "button" or new_btns[1]._is_capi_button
) or false
end, true)
local function setup_signals(_wibox)
local obj
local function clone_signal(name)
-- When "name" is emitted on wibox.drawin, also emit it on wibox
obj:connect_signal(name, function(_, ...)
_wibox:emit_signal(name, ...)
end)
end
obj = _wibox.drawin
clone_signal("property::border_color")
clone_signal("property::border_width")
clone_signal("property::buttons")
clone_signal("property::cursor")
clone_signal("property::height")
clone_signal("property::ontop")
clone_signal("property::opacity")
clone_signal("property::struts")
clone_signal("property::visible")
clone_signal("property::width")
clone_signal("property::x")
clone_signal("property::y")
clone_signal("property::geometry")
clone_signal("property::shape_bounding")
clone_signal("property::shape_clip")
clone_signal("property::shape_input")
obj = _wibox._drawable
clone_signal("button::press")
clone_signal("button::release")
clone_signal("mouse::enter")
clone_signal("mouse::leave")
clone_signal("mouse::move")
clone_signal("property::surface")
end
--- Create a wibox.
-- @tparam[opt=nil] table args
-- @tparam integer args.border_width Border width.
-- @tparam string args.border_color Border color.
-- @tparam[opt=false] boolean args.ontop On top of other windows.
-- @tparam string args.cursor The mouse cursor.
-- @tparam boolean args.visible Visibility.
-- @tparam[opt=1] number args.opacity The opacity, between 0 and 1.
-- @tparam string args.type The window type (desktop, normal, dock, …).
-- @tparam integer args.x The x coordinates.
-- @tparam integer args.y The y coordinates.
-- @tparam integer args.width The width.
-- @tparam integer args.height The height.
-- @tparam screen args.screen The wibox screen.
-- @tparam wibox.widget args.widget The widget that the wibox displays.
-- @param args.shape_bounding The wibox’s bounding shape as a (native) cairo surface.
-- @param args.shape_clip The wibox’s clip shape as a (native) cairo surface.
-- @param args.shape_input The wibox’s input shape as a (native) cairo surface.
-- @tparam color args.bg The background.
-- @tparam surface args.bgimage The background image of the drawable.
-- @tparam color args.fg The foreground (text) color.
-- @tparam gears.shape args.shape The shape.
-- @tparam[opt=false] boolean args.input_passthrough If the inputs are
-- forward to the element below.
-- @treturn wibox The new wibox
-- @constructorfct wibox
local function new(args)
args = args or {}
local ret = object()
local w = capi.drawin(args)
function w.get_wibox()
return ret
end
ret.drawin = w
ret._drawable = wibox.drawable(w.drawable, { wibox = ret },
"wibox drawable (" .. object.modulename(3) .. ")")
function ret._drawable.get_wibox()
return ret
end
ret._drawable:_inform_visible(w.visible)
w:connect_signal("property::visible", function()
ret._drawable:_inform_visible(w.visible)
end)
--TODO v5 deprecate this and use `wibox.object`.
for k, v in pairs(wibox) do
if (not rawget(ret, k)) and type(v) == "function" then
ret[k] = v
end
end
setup_signals(ret)
ret.draw = ret._drawable.draw
-- Set the default background
ret:set_bg(args.bg or beautiful.bg_normal)
ret:set_fg(args.fg or beautiful.fg_normal)
-- Add __tostring method to metatable.
local mt = {}
local orig_string = tostring(ret)
mt.__tostring = function()
return string.format("wibox: %s (%s)",
tostring(ret._drawable), orig_string)
end
ret = setmetatable(ret, mt)
-- Make sure the wibox is drawn at least once
ret.draw()
ret:connect_signal("property::geometry", ret._apply_shape)
ret:connect_signal("property::border_width", ret._apply_shape)
-- If a value is not found, look in the drawin
setmetatable(ret, {
__index = function(self, k)
if rawget(self, "get_"..k) then
return self["get_"..k](self)
else
return w[k]
end
end,
__newindex = function(self, k,v)
if rawget(self, "set_"..k) then
self["set_"..k](self, v)
elseif force_forward[k] or w[k] ~= nil then
w[k] = v
else
rawset(self, k, v)
end
end
})
-- Set other wibox specific arguments
if args.bgimage then
ret:set_bgimage( args.bgimage )
end
if args.widget then
ret:set_widget ( args.widget )
end
if args.screen then
ret:set_screen ( args.screen )
end
if args.shape then
ret.shape = args.shape
end
if args.border_width then
ret.border_width = args.border_width
end
if args.border_color then
ret.border_color = args.border_color
end
if args.opacity then
ret.opacity = args.opacity
end
if args.input_passthrough then
ret.input_passthrough = args.input_passthrough
end
-- Make sure all signals bubble up
ret:_connect_everything(wibox.emit_signal)
return ret
end
--- Redraw a wibox. You should never have to call this explicitely because it is
-- automatically called when needed.
-- @param wibox
-- @method draw
--- Connect a global signal on the wibox class.
--
-- Functions connected to this signal source will be executed when any
-- wibox object emits the signal.
--
-- It is also used for some generic wibox signals such as
-- `request::geometry`.
--
-- @tparam string name The name of the signal
-- @tparam function func The function to attach
-- @staticfct wibox.connect_signal
-- @usage wibox.connect_signal("added", function(notif)
-- -- do something
-- end)
--- Emit a wibox signal.
-- @tparam string name The signal name.
-- @param ... The signal callback arguments
-- @staticfct wibox.emit_signal
--- Disconnect a signal from a source.
-- @tparam string name The name of the signal
-- @tparam function func The attached function
-- @staticfct wibox.disconnect_signal
-- @treturn boolean If the disconnection was successful
function wibox.mt:__call(...)
return new(...)
end
-- Extend the luaobject
object.properties(capi.drawin, {
getter_class = wibox.object,
setter_class = wibox.object,
auto_emit = true,
})
capi.drawin.object = wibox.object
object._setup_class_signals(wibox)
return setmetatable(wibox, wibox.mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
do
local _ = {
['character-corpse'] = {
icon = '__core__/graphics/icons/entity/character.png',
name = 'character-corpse',
icon_mipmaps = 4,
armor_picture_mapping = {
['modular-armor'] = 3,
['heavy-armor'] = 2,
['light-armor'] = 2,
['power-armor'] = 3,
['power-armor-mk2'] = 3
},
close_sound = {filename = '__base__/sound/character-corpse-close.ogg', volume = 0.5},
pictures = {
{
layers = {
{
filename = '__base__/graphics/entity/character/level1_dead.png',
frame_count = 2,
height = 58,
width = 58,
shift = {-0.21875, -0.15625},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level1_dead.png',
frame_count = 2,
height = 112,
width = 114,
shift = {-0.21875, -0.171875},
scale = 0.5
}
}, {
filename = '__base__/graphics/entity/character/level1_dead_mask.png',
width = 46,
frame_count = 2,
height = 36,
shift = {-0.0625, -0.1875},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level1_dead_mask.png',
width = 88,
frame_count = 2,
height = 70,
shift = {-0.078125, -0.203125},
scale = 0.5,
apply_runtime_tint = true
},
apply_runtime_tint = true
}, {
filename = '__base__/graphics/entity/character/level1_dead_shadow.png',
draw_as_shadow = true,
frame_count = 2,
height = 54,
width = 54,
shift = {-0.125, -0.09375},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level1_dead_shadow.png',
draw_as_shadow = true,
frame_count = 2,
height = 106,
width = 108,
shift = {-0.109375, -0.09375},
scale = 0.5
}
}
}
}, {
layers = {
0, 0, {
filename = '__base__/graphics/entity/character/level2addon_dead.png',
frame_count = 2,
height = 34,
width = 44,
shift = {-0.03125, -0.15625},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level2addon_dead.png',
frame_count = 2,
height = 68,
width = 86,
shift = {-0.03125, -0.15625},
scale = 0.5
}
}, {
filename = '__base__/graphics/entity/character/level2addon_dead_mask.png',
width = 44,
frame_count = 2,
height = 34,
shift = {0, -0.15625},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level2addon_dead_mask.png',
width = 86,
frame_count = 2,
height = 66,
shift = {-0.015625, -0.171875},
scale = 0.5,
apply_runtime_tint = true
},
apply_runtime_tint = true
}, 0
}
}, {
layers = {
0, 0, {
filename = '__base__/graphics/entity/character/level3addon_dead.png',
frame_count = 2,
height = 34,
width = 44,
shift = {-0.03125, -0.15625},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level3addon_dead.png',
frame_count = 2,
height = 68,
width = 88,
shift = {-0.015625, -0.15625},
scale = 0.5
}
}, {
filename = '__base__/graphics/entity/character/level3addon_dead_mask.png',
width = 36,
frame_count = 2,
height = 30,
shift = {0.09375, -0.125},
hr_version = {
filename = '__base__/graphics/entity/character/hr-level3addon_dead_mask.png',
width = 72,
frame_count = 2,
height = 60,
shift = {0.09375, -0.109375},
scale = 0.5,
apply_runtime_tint = true
},
apply_runtime_tint = true
}, 0
}
}
},
flags = {'placeable-off-grid', 'not-rotatable', 'not-on-map'},
type = 'character-corpse',
time_to_live = 54000,
icon_size = 64,
selection_box = {{-0.7, -0.7}, {0.7, 0.7}},
open_sound = {filename = '__base__/sound/character-corpse-open.ogg', volume = 0.5},
selection_priority = 100,
minable = {mining_time = 2}
}
};
return _;
end
|
--[[
выполняет функцию для всех обьектов из таблицы
если функция возвращает false - то происходит досрочный выход из цикла
]]
function ForEachInTable (t, func, ...)
local index, value = next (t)
while index do
if func (value, ...)==false then
return
end
index, value = next (t, index)
end
end
|
--!A cross-platform build utility based on Lua
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
-- @file get_requires.lua
--
-- imports
import("core.base.option")
import("core.project.project")
-- get requires and extra config
function main(requires)
-- init requires
local requires_extra = nil
if not requires then
requires, requires_extra = project.requires_str()
end
if not requires or #requires == 0 then
return
end
-- get extra info
local extra = option.get("extra")
local extrainfo = nil
if extra then
local v, err = string.deserialize(extra)
if err then
raise(err)
else
extrainfo = v
end
end
-- force to use the given requires extra info
if extrainfo then
requires_extra = requires_extra or {}
for _, require_str in ipairs(requires) do
requires_extra[require_str] = extrainfo
end
end
return requires, requires_extra
end
|
local icons = require('icons')
require('notify').setup({
timeout = 3000,
stages = 'fade',
icons = {
ERROR = icons.diagnostics.Error,
WARN = icons.diagnostics.Warning,
INFO = icons.diagnostics.Information,
DEBUG = icons.diagnostics.Debug,
TRACE = icons.diagnostics.Trace,
},
background_colour = require('nightfox.colors').init().bg,
})
|
--freetype/*.h from freetype 2.9.1
require'ffi'.cdef[[
// config/ftconfig.h ---------------------------------------------------------
typedef signed short FT_Int16;
typedef unsigned short FT_UInt16;
typedef signed int FT_Int32;
typedef unsigned int FT_UInt32;
typedef int FT_Fast;
typedef unsigned int FT_UFast;
// fttypes.h -----------------------------------------------------------------
typedef unsigned char FT_Bool;
typedef signed short FT_FWord;
typedef unsigned short FT_UFWord;
typedef signed char FT_Char;
typedef unsigned char FT_Byte;
typedef const FT_Byte* FT_Bytes;
typedef FT_UInt32 FT_Tag;
typedef char FT_String;
typedef signed short FT_Short;
typedef unsigned short FT_UShort;
typedef signed int FT_Int;
typedef unsigned int FT_UInt;
typedef signed long FT_Long;
typedef unsigned long FT_ULong;
typedef signed short FT_F2Dot14;
typedef signed long FT_F26Dot6;
typedef signed long FT_Fixed;
typedef int FT_Error;
typedef void* FT_Pointer;
typedef size_t FT_Offset;
typedef ptrdiff_t FT_PtrDist;
typedef struct FT_UnitVector_ {
FT_F2Dot14 x;
FT_F2Dot14 y;
} FT_UnitVector;
typedef struct FT_Matrix_ {
FT_Fixed xx, xy;
FT_Fixed yx, yy;
} FT_Matrix;
typedef struct FT_Data_ {
const FT_Byte* pointer;
FT_Int length;
} FT_Data;
typedef void (*FT_Generic_Finalizer)( void* object );
typedef struct FT_Generic_ {
void* data;
FT_Generic_Finalizer finalizer;
} FT_Generic;
typedef struct FT_ListNodeRec_* FT_ListNode;
typedef struct FT_ListRec_* FT_List;
typedef struct FT_ListNodeRec_ {
FT_ListNode prev;
FT_ListNode next;
void* data;
} FT_ListNodeRec;
typedef struct FT_ListRec_ {
FT_ListNode head;
FT_ListNode tail;
} FT_ListRec;
// ftsystem.h ----------------------------------------------------------------
typedef struct FT_MemoryRec_* FT_Memory;
typedef void* (*FT_Alloc_Func) ( FT_Memory memory, long size );
typedef void (*FT_Free_Func) ( FT_Memory memory, void* block );
typedef void* (*FT_Realloc_Func) ( FT_Memory memory, long cur_size, long new_size, void* block );
struct FT_MemoryRec_ {
void* user;
FT_Alloc_Func alloc;
FT_Free_Func free;
FT_Realloc_Func realloc;
};
typedef struct FT_StreamRec_* FT_Stream;
typedef union FT_StreamDesc_ {
long value;
void* pointer;
} FT_StreamDesc;
typedef unsigned long (*FT_Stream_IoFunc)(
FT_Stream stream,
unsigned long offset,
unsigned char* buffer,
unsigned long count );
typedef void (*FT_Stream_CloseFunc)( FT_Stream stream );
typedef struct FT_StreamRec_ {
unsigned char* base;
unsigned long size;
unsigned long pos;
FT_StreamDesc descriptor;
FT_StreamDesc pathname;
FT_Stream_IoFunc read;
FT_Stream_CloseFunc close;
FT_Memory memory;
unsigned char* cursor;
unsigned char* limit;
} FT_StreamRec;
// ftimage.h -----------------------------------------------------------------
typedef signed long FT_Pos;
typedef struct FT_Vector_ {
FT_Pos x;
FT_Pos y;
} FT_Vector;
typedef struct FT_BBox_ {
FT_Pos xMin, yMin;
FT_Pos xMax, yMax;
} FT_BBox;
typedef enum FT_Pixel_Mode_ {
FT_PIXEL_MODE_NONE = 0,
FT_PIXEL_MODE_MONO,
FT_PIXEL_MODE_GRAY,
FT_PIXEL_MODE_GRAY2,
FT_PIXEL_MODE_GRAY4,
FT_PIXEL_MODE_LCD,
FT_PIXEL_MODE_LCD_V,
FT_PIXEL_MODE_BGRA,
} FT_Pixel_Mode;
typedef struct FT_Bitmap_ {
unsigned int rows;
unsigned int width;
int pitch;
unsigned char* buffer;
unsigned short num_grays;
unsigned char pixel_mode;
unsigned char palette_mode;
void* palette;
} FT_Bitmap;
typedef struct FT_Outline_ {
short n_contours;
short n_points;
FT_Vector* points;
char* tags;
short* contours;
int flags;
} FT_Outline;
enum {
FT_OUTLINE_CONTOURS_MAX = 32767,
FT_OUTLINE_POINTS_MAX = 32767,
FT_OUTLINE_NONE = 0x0,
FT_OUTLINE_OWNER = 0x1,
FT_OUTLINE_EVEN_ODD_FILL = 0x2,
FT_OUTLINE_REVERSE_FILL = 0x4,
FT_OUTLINE_IGNORE_DROPOUTS = 0x8,
FT_OUTLINE_SMART_DROPOUTS = 0x10,
FT_OUTLINE_INCLUDE_STUBS = 0x20,
FT_OUTLINE_HIGH_PRECISION = 0x100,
FT_OUTLINE_SINGLE_PASS = 0x200,
};
enum {
FT_CURVE_TAG_ON = 1,
FT_CURVE_TAG_CONIC = 0,
FT_CURVE_TAG_CUBIC = 2,
FT_CURVE_TAG_HAS_SCANMODE = 4,
FT_CURVE_TAG_TOUCH_X = 8,
FT_CURVE_TAG_TOUCH_Y = 16,
FT_CURVE_TAG_TOUCH_BOTH = ( FT_CURVE_TAG_TOUCH_X | FT_CURVE_TAG_TOUCH_Y ),
};
typedef int (*FT_Outline_MoveToFunc) ( const FT_Vector* to, void* user );
typedef int (*FT_Outline_LineToFunc) ( const FT_Vector* to, void* user );
typedef int (*FT_Outline_ConicToFunc)( const FT_Vector* control, const FT_Vector* to, void* user );
typedef int (*FT_Outline_CubicToFunc)( const FT_Vector* control1, const FT_Vector* control2, const FT_Vector* to, void* user );
typedef struct FT_Outline_Funcs_ {
FT_Outline_MoveToFunc move_to;
FT_Outline_LineToFunc line_to;
FT_Outline_ConicToFunc conic_to;
FT_Outline_CubicToFunc cubic_to;
int shift;
FT_Pos delta;
} FT_Outline_Funcs;
typedef enum FT_Glyph_Format_ {
FT_GLYPH_FORMAT_NONE = ( ( (unsigned long)0 << 24 ) | ( (unsigned long)0 << 16 ) | ( (unsigned long)0 << 8 ) | (unsigned long)0 ),
FT_GLYPH_FORMAT_COMPOSITE = ( ( (unsigned long)'c' << 24 ) | ( (unsigned long)'o' << 16 ) | ( (unsigned long)'m' << 8 ) | (unsigned long)'p' ),
FT_GLYPH_FORMAT_BITMAP = ( ( (unsigned long)'b' << 24 ) | ( (unsigned long)'i' << 16 ) | ( (unsigned long)'t' << 8 ) | (unsigned long)'s' ),
FT_GLYPH_FORMAT_OUTLINE = ( ( (unsigned long)'o' << 24 ) | ( (unsigned long)'u' << 16 ) | ( (unsigned long)'t' << 8 ) | (unsigned long)'l' ),
FT_GLYPH_FORMAT_PLOTTER = ( ( (unsigned long)'p' << 24 ) | ( (unsigned long)'l' << 16 ) | ( (unsigned long)'o' << 8 ) | (unsigned long)'t' )
} FT_Glyph_Format;
typedef struct FT_RasterRec_* FT_Raster;
typedef struct FT_Span_ {
short x;
unsigned short len;
unsigned char coverage;
} FT_Span;
typedef void (*FT_SpanFunc)( int y, int count, const FT_Span* spans, void* user );
typedef int (*FT_Raster_BitTest_Func)( int y, int x, void* user );
typedef void (*FT_Raster_BitSet_Func)( int y, int x, void* user );
enum {
FT_RASTER_FLAG_DEFAULT = 0x0,
FT_RASTER_FLAG_AA = 0x1,
FT_RASTER_FLAG_DIRECT = 0x2,
FT_RASTER_FLAG_CLIP = 0x4,
};
typedef struct FT_Raster_Params_ {
const FT_Bitmap* target;
const void* source;
int flags;
FT_SpanFunc gray_spans;
FT_SpanFunc black_spans;
FT_Raster_BitTest_Func bit_test;
FT_Raster_BitSet_Func bit_set;
void* user;
FT_BBox clip_box;
} FT_Raster_Params;
typedef int (*FT_Raster_NewFunc)( void* memory, FT_Raster* raster );
typedef void (*FT_Raster_DoneFunc)( FT_Raster raster );
typedef void (*FT_Raster_ResetFunc)( FT_Raster raster,
unsigned char* pool_base,
unsigned long pool_size );
typedef int (*FT_Raster_SetModeFunc)( FT_Raster raster,
unsigned long mode,
void* args );
typedef int (*FT_Raster_RenderFunc)( FT_Raster raster,
const FT_Raster_Params* params );
typedef struct FT_Raster_Funcs_ {
FT_Glyph_Format glyph_format;
FT_Raster_NewFunc raster_new;
FT_Raster_ResetFunc raster_reset;
FT_Raster_SetModeFunc raster_set_mode;
FT_Raster_RenderFunc raster_render;
FT_Raster_DoneFunc raster_done;
} FT_Raster_Funcs;
// freetype.h ----------------------------------------------------------------
typedef struct FT_Glyph_Metrics_ {
FT_Pos width;
FT_Pos height;
FT_Pos horiBearingX;
FT_Pos horiBearingY;
FT_Pos horiAdvance;
FT_Pos vertBearingX;
FT_Pos vertBearingY;
FT_Pos vertAdvance;
} FT_Glyph_Metrics;
typedef struct FT_Bitmap_Size_ {
FT_Short height;
FT_Short width;
FT_Pos size;
FT_Pos x_ppem;
FT_Pos y_ppem;
} FT_Bitmap_Size;
typedef struct FT_LibraryRec_ *FT_Library;
typedef struct FT_ModuleRec_* FT_Module;
typedef struct FT_DriverRec_* FT_Driver;
typedef struct FT_RendererRec_* FT_Renderer;
typedef struct FT_FaceRec_* FT_Face;
typedef struct FT_SizeRec_* FT_Size;
typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
typedef struct FT_CharMapRec_* FT_CharMap;
typedef enum FT_Encoding_ {
FT_ENCODING_NONE = ( ( (FT_UInt32)(0) << 24 ) | ( (FT_UInt32)(0) << 16 ) | ( (FT_UInt32)(0) << 8 ) | (FT_UInt32)(0) ),
FT_ENCODING_MS_SYMBOL = ( ( (FT_UInt32)('s') << 24 ) | ( (FT_UInt32)('y') << 16 ) | ( (FT_UInt32)('m') << 8 ) | (FT_UInt32)('b') ),
FT_ENCODING_UNICODE = ( ( (FT_UInt32)('u') << 24 ) | ( (FT_UInt32)('n') << 16 ) | ( (FT_UInt32)('i') << 8 ) | (FT_UInt32)('c') ),
FT_ENCODING_SJIS = ( ( (FT_UInt32)('s') << 24 ) | ( (FT_UInt32)('j') << 16 ) | ( (FT_UInt32)('i') << 8 ) | (FT_UInt32)('s') ),
FT_ENCODING_PRC = ( ( (FT_UInt32)('g') << 24 ) | ( (FT_UInt32)('b') << 16 ) | ( (FT_UInt32)(' ') << 8 ) | (FT_UInt32)(' ') ),
FT_ENCODING_BIG5 = ( ( (FT_UInt32)('b') << 24 ) | ( (FT_UInt32)('i') << 16 ) | ( (FT_UInt32)('g') << 8 ) | (FT_UInt32)('5') ),
FT_ENCODING_WANSUNG = ( ( (FT_UInt32)('w') << 24 ) | ( (FT_UInt32)('a') << 16 ) | ( (FT_UInt32)('n') << 8 ) | (FT_UInt32)('s') ),
FT_ENCODING_JOHAB = ( ( (FT_UInt32)('j') << 24 ) | ( (FT_UInt32)('o') << 16 ) | ( (FT_UInt32)('h') << 8 ) | (FT_UInt32)('a') ),
FT_ENCODING_GB2312 = FT_ENCODING_PRC,
FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
FT_ENCODING_ADOBE_STANDARD = ( ( (FT_UInt32)('A') << 24 ) | ( (FT_UInt32)('D') << 16 ) | ( (FT_UInt32)('O') << 8 ) | (FT_UInt32)('B') ),
FT_ENCODING_ADOBE_EXPERT = ( ( (FT_UInt32)('A') << 24 ) | ( (FT_UInt32)('D') << 16 ) | ( (FT_UInt32)('B') << 8 ) | (FT_UInt32)('E') ),
FT_ENCODING_ADOBE_CUSTOM = ( ( (FT_UInt32)('A') << 24 ) | ( (FT_UInt32)('D') << 16 ) | ( (FT_UInt32)('B') << 8 ) | (FT_UInt32)('C') ),
FT_ENCODING_ADOBE_LATIN_1 = ( ( (FT_UInt32)('l') << 24 ) | ( (FT_UInt32)('a') << 16 ) | ( (FT_UInt32)('t') << 8 ) | (FT_UInt32)('1') ),
FT_ENCODING_OLD_LATIN_2 = ( ( (FT_UInt32)('l') << 24 ) | ( (FT_UInt32)('a') << 16 ) | ( (FT_UInt32)('t') << 8 ) | (FT_UInt32)('2') ),
FT_ENCODING_APPLE_ROMAN = ( ( (FT_UInt32)('a') << 24 ) | ( (FT_UInt32)('r') << 16 ) | ( (FT_UInt32)('m') << 8 ) | (FT_UInt32)('n') )
} FT_Encoding;
typedef struct FT_CharMapRec_ {
FT_Face face;
union {
FT_Encoding encoding;
char _encoding_str[4];
};
FT_UShort platform_id;
FT_UShort encoding_id;
} FT_CharMapRec;
typedef struct FT_Face_InternalRec_* FT_Face_Internal;
typedef struct FT_FaceRec_ {
FT_Long num_faces;
FT_Long face_index;
FT_Long face_flags;
FT_Long style_flags;
FT_Long num_glyphs;
FT_String* family_name;
FT_String* style_name;
FT_Int num_fixed_sizes;
FT_Bitmap_Size* available_sizes;
FT_Int num_charmaps;
FT_CharMap* charmaps;
FT_Generic generic;
FT_BBox bbox;
FT_UShort units_per_EM;
FT_Short ascender;
FT_Short descender;
FT_Short height;
FT_Short max_advance_width;
FT_Short max_advance_height;
FT_Short underline_position;
FT_Short underline_thickness;
FT_GlyphSlot glyph;
FT_Size size;
FT_CharMap charmap;
FT_Driver driver;
FT_Memory memory;
FT_Stream stream;
FT_ListRec sizes_list;
FT_Generic autohint;
void* extensions;
FT_Face_Internal internal;
} FT_FaceRec;
enum {
FT_FACE_FLAG_SCALABLE = ( 1 << 0 ),
FT_FACE_FLAG_FIXED_SIZES = ( 1 << 1 ),
FT_FACE_FLAG_FIXED_WIDTH = ( 1 << 2 ),
FT_FACE_FLAG_SFNT = ( 1 << 3 ),
FT_FACE_FLAG_HORIZONTAL = ( 1 << 4 ),
FT_FACE_FLAG_VERTICAL = ( 1 << 5 ),
FT_FACE_FLAG_KERNING = ( 1 << 6 ),
FT_FACE_FLAG_FAST_GLYPHS = ( 1 << 7 ),
FT_FACE_FLAG_MULTIPLE_MASTERS = ( 1 << 8 ),
FT_FACE_FLAG_GLYPH_NAMES = ( 1 << 9 ),
FT_FACE_FLAG_EXTERNAL_STREAM = ( 1 << 10 ),
FT_FACE_FLAG_HINTER = ( 1 << 11 ),
FT_FACE_FLAG_CID_KEYED = ( 1 << 12 ),
FT_FACE_FLAG_TRICKY = ( 1 << 13 ),
FT_FACE_FLAG_COLOR = ( 1 << 14 ),
FT_FACE_FLAG_VARIATION = ( 1 << 15 ),
};
enum {
FT_STYLE_FLAG_ITALIC = ( 1 << 0 ),
FT_STYLE_FLAG_BOLD = ( 1 << 1 ),
};
typedef struct FT_Size_InternalRec_* FT_Size_Internal;
typedef struct FT_Size_Metrics_ {
FT_UShort x_ppem;
FT_UShort y_ppem;
FT_Fixed x_scale;
FT_Fixed y_scale;
FT_Pos ascender;
FT_Pos descender;
FT_Pos height;
FT_Pos max_advance;
} FT_Size_Metrics;
typedef struct FT_SizeRec_ {
FT_Face face;
FT_Generic generic;
FT_Size_Metrics metrics;
FT_Size_Internal internal;
} FT_SizeRec;
typedef struct FT_SubGlyphRec_* FT_SubGlyph;
typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
typedef struct FT_GlyphSlotRec_ {
FT_Library library;
FT_Face face;
FT_GlyphSlot next;
FT_UInt reserved;
FT_Generic generic;
FT_Glyph_Metrics metrics;
FT_Fixed linearHoriAdvance;
FT_Fixed linearVertAdvance;
FT_Vector advance;
FT_Glyph_Format format;
FT_Bitmap bitmap;
FT_Int bitmap_left;
FT_Int bitmap_top;
FT_Outline outline;
FT_UInt num_subglyphs;
FT_SubGlyph subglyphs;
void* control_data;
long control_len;
FT_Pos lsb_delta;
FT_Pos rsb_delta;
void* other;
FT_Slot_Internal internal;
} FT_GlyphSlotRec;
FT_Error FT_Init_FreeType( FT_Library *alibrary );
FT_Error FT_Done_FreeType( FT_Library library );
enum {
FT_OPEN_MEMORY = 0x1,
FT_OPEN_STREAM = 0x2,
FT_OPEN_PATHNAME = 0x4,
FT_OPEN_DRIVER = 0x8,
FT_OPEN_PARAMS = 0x10,
};
typedef struct FT_Parameter_ {
FT_ULong tag;
FT_Pointer data;
} FT_Parameter;
typedef struct FT_Open_Args_ {
FT_UInt flags;
const FT_Byte* memory_base;
FT_Long memory_size;
FT_String* pathname;
FT_Stream stream;
FT_Module driver;
FT_Int num_params;
FT_Parameter* params;
} FT_Open_Args;
FT_Error
FT_New_Face(
FT_Library library,
const char* filepathname,
FT_Long face_index,
FT_Face *aface );
FT_Error
FT_New_Memory_Face(
FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface );
FT_Error
FT_Open_Face(
FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface );
FT_Error FT_Attach_File ( FT_Face face, const char* filepathname );
FT_Error FT_Attach_Stream ( FT_Face face, FT_Open_Args* parameters );
FT_Error FT_Reference_Face ( FT_Face face );
FT_Error FT_Done_Face ( FT_Face face );
FT_Error FT_Select_Size ( FT_Face face, FT_Int strike_index );
typedef enum FT_Size_Request_Type_ {
FT_SIZE_REQUEST_TYPE_NOMINAL,
FT_SIZE_REQUEST_TYPE_REAL_DIM,
FT_SIZE_REQUEST_TYPE_BBOX,
FT_SIZE_REQUEST_TYPE_CELL,
FT_SIZE_REQUEST_TYPE_SCALES,
FT_SIZE_REQUEST_TYPE_MAX
} FT_Size_Request_Type;
typedef struct FT_Size_RequestRec_ {
FT_Size_Request_Type type;
FT_Long width;
FT_Long height;
FT_UInt horiResolution;
FT_UInt vertResolution;
} FT_Size_RequestRec;
typedef struct FT_Size_RequestRec_ *FT_Size_Request;
FT_Error
FT_Request_Size(
FT_Face face,
FT_Size_Request req );
FT_Error
FT_Set_Char_Size(
FT_Face face,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution );
FT_Error
FT_Set_Pixel_Sizes(
FT_Face face,
FT_UInt pixel_width,
FT_UInt pixel_height );
FT_Error
FT_Load_Glyph(
FT_Face face,
FT_UInt glyph_index,
FT_Int32 load_flags );
FT_Error
FT_Load_Char(
FT_Face face,
FT_ULong char_code,
FT_Int32 load_flags );
enum {
FT_LOAD_DEFAULT = 0x0,
FT_LOAD_NO_SCALE = ( 1 << 0 ),
FT_LOAD_NO_HINTING = ( 1 << 1 ),
FT_LOAD_RENDER = ( 1 << 2 ),
FT_LOAD_NO_BITMAP = ( 1 << 3 ),
FT_LOAD_VERTICAL_LAYOUT = ( 1 << 4 ),
FT_LOAD_FORCE_AUTOHINT = ( 1 << 5 ),
FT_LOAD_CROP_BITMAP = ( 1 << 6 ), // ignored, deprecated
FT_LOAD_PEDANTIC = ( 1 << 7 ),
FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = ( 1 << 9 ), // ignored, deprecated
FT_LOAD_NO_RECURSE = ( 1 << 10 ),
FT_LOAD_IGNORE_TRANSFORM = ( 1 << 11 ),
FT_LOAD_MONOCHROME = ( 1 << 12 ),
FT_LOAD_LINEAR_DESIGN = ( 1 << 13 ),
FT_LOAD_NO_AUTOHINT = ( 1 << 15 ),
FT_LOAD_COLOR = ( 1 << 20 ),
FT_LOAD_COMPUTE_METRICS = ( 1 << 21 ),
FT_LOAD_BITMAP_METRICS_ONLY = ( 1 << 22 ),
FT_LOAD_ADVANCE_ONLY = ( 1 << 8 ),
FT_LOAD_SBITS_ONLY = ( 1 << 14 ),
};
typedef enum FT_Render_Mode_ {
FT_RENDER_MODE_NORMAL = 0,
FT_RENDER_MODE_LIGHT,
FT_RENDER_MODE_MONO,
FT_RENDER_MODE_LCD,
FT_RENDER_MODE_LCD_V,
FT_RENDER_MODE_MAX
} FT_Render_Mode;
enum {
FT_LOAD_TARGET_NORMAL = (FT_RENDER_MODE_NORMAL & 15) << 16,
FT_LOAD_TARGET_LIGHT = (FT_RENDER_MODE_LIGHT & 15) << 16,
FT_LOAD_TARGET_MONO = (FT_RENDER_MODE_MONO & 15) << 16,
FT_LOAD_TARGET_LCD = (FT_RENDER_MODE_LCD & 15) << 16,
FT_LOAD_TARGET_LCD_V = (FT_RENDER_MODE_LCD_V & 15) << 16
};
void FT_Set_Transform( FT_Face face, FT_Matrix* matrix, FT_Vector* delta );
FT_Error FT_Render_Glyph( FT_GlyphSlot slot, FT_Render_Mode render_mode );
typedef enum FT_Kerning_Mode_ {
FT_KERNING_DEFAULT = 0,
FT_KERNING_UNFITTED,
FT_KERNING_UNSCALED
} FT_Kerning_Mode;
FT_Error
FT_Get_Kerning(
FT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_UInt kern_mode,
FT_Vector *akerning );
FT_Error
FT_Get_Track_Kerning(
FT_Face face,
FT_Fixed point_size,
FT_Int degree,
FT_Fixed* akerning );
FT_Error
FT_Get_Glyph_Name(
FT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max );
const char* FT_Get_Postscript_Name( FT_Face face );
FT_Error FT_Select_Charmap( FT_Face face, FT_Encoding encoding );
FT_Error FT_Set_Charmap( FT_Face face, FT_CharMap charmap );
FT_Int FT_Get_Charmap_Index( FT_CharMap charmap );
FT_UInt FT_Get_Char_Index( FT_Face face, FT_ULong charcode );
FT_ULong FT_Get_First_Char( FT_Face face, FT_UInt *agindex );
FT_ULong FT_Get_Next_Char( FT_Face face, FT_ULong char_code, FT_UInt *agindex );
FT_Error FT_Face_Properties( FT_Face face, FT_UInt num_properties, FT_Parameter* properties );
FT_UInt FT_Get_Name_Index( FT_Face face, FT_String* glyph_name );
enum {
FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS = 1,
FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES = 2,
FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID = 4,
FT_SUBGLYPH_FLAG_SCALE = 8,
FT_SUBGLYPH_FLAG_XY_SCALE = 0x40,
FT_SUBGLYPH_FLAG_2X2 = 0x80,
FT_SUBGLYPH_FLAG_USE_MY_METRICS = 0x200,
};
FT_Error
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
FT_UInt sub_index,
FT_Int *p_index,
FT_UInt *p_flags,
FT_Int *p_arg1,
FT_Int *p_arg2,
FT_Matrix *p_transform );
enum {
FT_FSTYPE_INSTALLABLE_EMBEDDING = 0x0000,
FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING = 0x0002,
FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING = 0x0004,
FT_FSTYPE_EDITABLE_EMBEDDING = 0x0008,
FT_FSTYPE_NO_SUBSETTING = 0x0100,
FT_FSTYPE_BITMAP_EMBEDDING_ONLY = 0x0200,
};
FT_UShort FT_Get_FSType_Flags ( FT_Face face );
FT_UInt FT_Face_GetCharVariantIndex ( FT_Face face, FT_ULong charcode, FT_ULong variantSelector );
FT_Int FT_Face_GetCharVariantIsDefault ( FT_Face face, FT_ULong charcode, FT_ULong variantSelector );
FT_UInt32* FT_Face_GetVariantSelectors ( FT_Face face );
FT_UInt32* FT_Face_GetVariantsOfChar ( FT_Face face, FT_ULong charcode );
FT_UInt32* FT_Face_GetCharsOfVariant ( FT_Face face, FT_ULong variantSelector );
FT_Long FT_MulDiv( FT_Long a, FT_Long b, FT_Long c );
FT_Long FT_MulFix( FT_Long a, FT_Long b );
FT_Long FT_DivFix( FT_Long a, FT_Long b );
FT_Fixed FT_RoundFix( FT_Fixed a );
FT_Fixed FT_CeilFix( FT_Fixed a );
FT_Fixed FT_FloorFix( FT_Fixed a );
void FT_Vector_Transform( FT_Vector* vec, const FT_Matrix* matrix );
void FT_Library_Version( FT_Library library,
FT_Int *amajor,
FT_Int *aminor,
FT_Int *apatch );
FT_Bool FT_Face_CheckTrueTypePatents( FT_Face face );
FT_Bool FT_Face_SetUnpatentedHinting( FT_Face face, FT_Bool value );
// ftbitmap.h ----------------------------------------------------------------
void FT_Bitmap_Init (FT_Bitmap *abitmap);
void FT_Bitmap_New (FT_Bitmap *abitmap);
FT_Error FT_Bitmap_Copy (FT_Library library, const FT_Bitmap *source, FT_Bitmap *target);
FT_Error FT_Bitmap_Embolden (FT_Library library, FT_Bitmap* bitmap, FT_Pos xStrength, FT_Pos yStrength);
FT_Error FT_Bitmap_Convert (FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment);
FT_Error FT_GlyphSlot_Own_Bitmap (FT_GlyphSlot slot);
FT_Error FT_Bitmap_Done (FT_Library library, FT_Bitmap *bitmap);
// ftglyph.h -----------------------------------------------------------------
typedef struct FT_Glyph_Class_ FT_Glyph_Class;
typedef struct FT_GlyphRec_* FT_Glyph;
typedef struct FT_GlyphRec_ {
FT_Library library;
const FT_Glyph_Class* clazz;
FT_Glyph_Format format;
FT_Vector advance;
} FT_GlyphRec;
typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
typedef struct FT_BitmapGlyphRec_ {
FT_GlyphRec root;
FT_Int left;
FT_Int top;
FT_Bitmap bitmap;
} FT_BitmapGlyphRec;
typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph;
typedef struct FT_OutlineGlyphRec_ {
FT_GlyphRec root;
FT_Outline outline;
} FT_OutlineGlyphRec;
FT_Error FT_Get_Glyph ( FT_GlyphSlot slot, FT_Glyph *aglyph );
FT_Error FT_Glyph_Copy ( FT_Glyph source, FT_Glyph *target );
FT_Error FT_Glyph_Transform ( FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta );
typedef enum FT_Glyph_BBox_Mode_ {
FT_GLYPH_BBOX_UNSCALED = 0,
FT_GLYPH_BBOX_SUBPIXELS = 0,
FT_GLYPH_BBOX_GRIDFIT = 1,
FT_GLYPH_BBOX_TRUNCATE = 2,
FT_GLYPH_BBOX_PIXELS = 3
} FT_Glyph_BBox_Mode;
void FT_Glyph_Get_CBox ( FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox );
FT_Error FT_Glyph_To_Bitmap ( FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, FT_Bool destroy );
void FT_Done_Glyph ( FT_Glyph glyph );
void FT_Matrix_Multiply ( const FT_Matrix* a, FT_Matrix* b );
FT_Error FT_Matrix_Invert ( FT_Matrix* matrix );
// ftoutln.h -----------------------------------------------------------------
FT_Error FT_Outline_Decompose ( FT_Outline* outline, const FT_Outline_Funcs* func_interface, void* user );
FT_Error FT_Outline_New ( FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline );
FT_Error FT_Outline_New_Internal ( FT_Memory memory, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline );
FT_Error FT_Outline_Done ( FT_Library library, FT_Outline* outline );
FT_Error FT_Outline_Done_Internal ( FT_Memory memory, FT_Outline* outline );
FT_Error FT_Outline_Check ( FT_Outline* outline );
void FT_Outline_Get_CBox ( const FT_Outline* outline, FT_BBox *acbox );
void FT_Outline_Translate ( const FT_Outline* outline, FT_Pos xOffset, FT_Pos yOffset );
FT_Error FT_Outline_Copy ( const FT_Outline* source, FT_Outline *target );
void FT_Outline_Transform ( const FT_Outline* outline, const FT_Matrix* matrix );
FT_Error FT_Outline_Embolden ( FT_Outline* outline, FT_Pos strength );
FT_Error FT_Outline_EmboldenXY ( FT_Outline* outline, FT_Pos xstrength, FT_Pos ystrength );
void FT_Outline_Reverse ( FT_Outline* outline );
FT_Error FT_Outline_Get_Bitmap ( FT_Library library, FT_Outline* outline, const FT_Bitmap *abitmap );
FT_Error FT_Outline_Render ( FT_Library library, FT_Outline* outline, FT_Raster_Params* params );
typedef enum FT_Orientation_ {
FT_ORIENTATION_TRUETYPE = 0,
FT_ORIENTATION_POSTSCRIPT = 1,
FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
FT_ORIENTATION_NONE
} FT_Orientation;
FT_Orientation FT_Outline_Get_Orientation( FT_Outline* outline );
// ftmodapi.h ----------------------------------------------------------------
enum {
FT_MODULE_FONT_DRIVER = 1,
FT_MODULE_RENDERER = 2,
FT_MODULE_HINTER = 4,
FT_MODULE_STYLER = 8,
FT_MODULE_DRIVER_SCALABLE = 0x100,
FT_MODULE_DRIVER_NO_OUTLINES = 0x200,
FT_MODULE_DRIVER_HAS_HINTER = 0x400,
FT_MODULE_DRIVER_HINTS_LIGHTLY = 0x800,
};
typedef FT_Pointer FT_Module_Interface;
typedef FT_Error (*FT_Module_Constructor)( FT_Module module );
typedef void (*FT_Module_Destructor)( FT_Module module );
typedef FT_Module_Interface(*FT_Module_Requester)(
FT_Module module,
const char* name );
typedef struct FT_Module_Class_ {
FT_ULong module_flags;
FT_Long module_size;
const FT_String* module_name;
FT_Fixed module_version;
FT_Fixed module_requires;
const void* module_interface;
FT_Module_Constructor module_init;
FT_Module_Destructor module_done;
FT_Module_Requester get_interface;
} FT_Module_Class;
FT_Error FT_Add_Module ( FT_Library library, const FT_Module_Class* clazz );
FT_Module FT_Get_Module ( FT_Library library, const char* module_name );
FT_Error FT_Remove_Module( FT_Library library, FT_Module module );
FT_Error FT_Property_Set(
FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
const void* value );
FT_Error FT_Property_Get(
FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
void* value );
void FT_Set_Default_Properties( FT_Library library );
FT_Error FT_Reference_Library ( FT_Library library );
FT_Error FT_New_Library ( FT_Memory memory, FT_Library *alibrary );
FT_Error FT_Done_Library ( FT_Library library );
typedef void (*FT_DebugHook_Func)( void* arg );
void FT_Set_Debug_Hook(
FT_Library library,
FT_UInt hook_index,
FT_DebugHook_Func debug_hook );
void FT_Add_Default_Modules(
FT_Library library );
typedef enum FT_TrueTypeEngineType_ {
FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
FT_TRUETYPE_ENGINE_TYPE_PATENTED
} FT_TrueTypeEngineType;
FT_TrueTypeEngineType FT_Get_TrueType_Engine_Type(
FT_Library library );
// ftcache.h -----------------------------------------------------------------
typedef FT_Pointer FTC_FaceID;
typedef FT_Error (*FTC_Face_Requester)(
FTC_FaceID face_id,
FT_Library library,
FT_Pointer req_data,
FT_Face* aface );
typedef struct FTC_ManagerRec_* FTC_Manager;
typedef struct FTC_NodeRec_* FTC_Node;
FT_Error FTC_Manager_New(
FT_Library library,
FT_UInt max_faces,
FT_UInt max_sizes,
FT_ULong max_bytes,
FTC_Face_Requester requester,
FT_Pointer req_data,
FTC_Manager *amanager );
void FTC_Manager_Reset( FTC_Manager manager );
void FTC_Manager_Done( FTC_Manager manager );
FT_Error FTC_Manager_LookupFace(
FTC_Manager manager,
FTC_FaceID face_id,
FT_Face *aface );
typedef struct FTC_ScalerRec_ {
FTC_FaceID face_id;
FT_UInt width;
FT_UInt height;
FT_Int pixel;
FT_UInt x_res;
FT_UInt y_res;
} FTC_ScalerRec;
typedef struct FTC_ScalerRec_* FTC_Scaler;
FT_Error FTC_Manager_LookupSize(
FTC_Manager manager,
FTC_Scaler scaler,
FT_Size *asize );
void FTC_Node_Unref(
FTC_Node node,
FTC_Manager manager );
void FTC_Manager_RemoveFaceID(
FTC_Manager manager,
FTC_FaceID face_id );
typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
FT_Error FTC_CMapCache_New(
FTC_Manager manager,
FTC_CMapCache *acache );
FT_UInt FTC_CMapCache_Lookup(
FTC_CMapCache cache,
FTC_FaceID face_id,
FT_Int cmap_index,
FT_UInt32 char_code );
typedef struct FTC_ImageTypeRec_ {
FTC_FaceID face_id;
FT_UInt width;
FT_UInt height;
FT_Int32 flags;
} FTC_ImageTypeRec;
typedef struct FTC_ImageTypeRec_* FTC_ImageType;
typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
FT_Error FTC_ImageCache_New(
FTC_Manager manager,
FTC_ImageCache *acache );
FT_Error FTC_ImageCache_Lookup(
FTC_ImageCache cache,
FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode );
FT_Error FTC_ImageCache_LookupScaler(
FTC_ImageCache cache,
FTC_Scaler scaler,
FT_ULong load_flags,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode );
typedef struct FTC_SBitRec_* FTC_SBit;
typedef struct FTC_SBitRec_ {
FT_Byte width;
FT_Byte height;
FT_Char left;
FT_Char top;
FT_Byte format;
FT_Byte max_grays;
FT_Short pitch;
FT_Char xadvance;
FT_Char yadvance;
FT_Byte* buffer;
} FTC_SBitRec;
typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
FT_Error FTC_SBitCache_New(
FTC_Manager manager,
FTC_SBitCache *acache );
FT_Error FTC_SBitCache_Lookup(
FTC_SBitCache cache,
FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *sbit,
FTC_Node *anode );
FT_Error FTC_SBitCache_LookupScaler(
FTC_SBitCache cache,
FTC_Scaler scaler,
FT_ULong load_flags,
FT_UInt gindex,
FTC_SBit *sbit,
FTC_Node *anode );
// ftstroke.h ----------------------------------------------------------------
typedef struct FT_StrokerRec_* FT_Stroker;
typedef enum FT_Stroker_LineJoin_ {
FT_STROKER_LINEJOIN_ROUND = 0,
FT_STROKER_LINEJOIN_BEVEL = 1,
FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
FT_STROKER_LINEJOIN_MITER_FIXED = 3
} FT_Stroker_LineJoin;
typedef enum FT_Stroker_LineCap_ {
FT_STROKER_LINECAP_BUTT = 0,
FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINECAP_SQUARE
} FT_Stroker_LineCap;
typedef enum FT_StrokerBorder_ {
FT_STROKER_BORDER_LEFT = 0,
FT_STROKER_BORDER_RIGHT
} FT_StrokerBorder;
FT_StrokerBorder FT_Outline_GetInsideBorder(
FT_Outline* outline );
FT_StrokerBorder FT_Outline_GetOutsideBorder(
FT_Outline* outline );
FT_Error FT_Stroker_New(
FT_Library library,
FT_Stroker *astroker );
void FT_Stroker_Set(
FT_Stroker stroker,
FT_Fixed radius,
FT_Stroker_LineCap line_cap,
FT_Stroker_LineJoin line_join,
FT_Fixed miter_limit );
void FT_Stroker_Rewind(
FT_Stroker stroker );
FT_Error FT_Stroker_ParseOutline(
FT_Stroker stroker,
FT_Outline* outline,
FT_Bool opened );
FT_Error FT_Stroker_BeginSubPath(
FT_Stroker stroker,
FT_Vector* to,
FT_Bool open );
FT_Error FT_Stroker_EndSubPath(
FT_Stroker stroker );
FT_Error FT_Stroker_LineTo(
FT_Stroker stroker,
FT_Vector* to );
FT_Error FT_Stroker_ConicTo(
FT_Stroker stroker,
FT_Vector* control,
FT_Vector* to );
FT_Error FT_Stroker_CubicTo(
FT_Stroker stroker,
FT_Vector* control1,
FT_Vector* control2,
FT_Vector* to );
FT_Error FT_Stroker_GetBorderCounts(
FT_Stroker stroker,
FT_StrokerBorder border,
FT_UInt *anum_points,
FT_UInt *anum_contours );
void FT_Stroker_ExportBorder(
FT_Stroker stroker,
FT_StrokerBorder border,
FT_Outline* outline );
FT_Error FT_Stroker_GetCounts(
FT_Stroker stroker,
FT_UInt *anum_points,
FT_UInt *anum_contours );
void FT_Stroker_Export(
FT_Stroker stroker,
FT_Outline* outline );
void FT_Stroker_Done( FT_Stroker stroker );
FT_Error FT_Glyph_Stroke(
FT_Glyph *pglyph,
FT_Stroker stroker,
FT_Bool destroy );
FT_Error FT_Glyph_StrokeBorder(
FT_Glyph *pglyph,
FT_Stroker stroker,
FT_Bool inside,
FT_Bool destroy );
]]
|
--[[
(C) Copyright 2014 William Dyce
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Lesser General Public License
(LGPL) version 2.1 which accompanies this distribution, and is available at
http://www.gnu.org/licenses/lgpl-2.1.html
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
--]]
--[[------------------------------------------------------------
Initialisation
--]]--
local Food = Class
{
FRICTION = 200,
type = GameObject.newType("Food"),
init = function(self, x, y)
GameObject.init(self, x, y, 6)
end,
}
Food:include(GameObject)
--[[------------------------------------------------------------
Destruction
--]]--
function Food:onPurge()
end
--[[------------------------------------------------------------
Game loop
--]]--
function Food:update(dt)
if self.x > LAND_W then
self.dx = self.dx - 128*dt
elseif self.x < 0 then
self.dx = self.dx + 128*dt
end
GameObject.update(self, dt)
end
function Food:draw(x, y)
fudge.addb("pie", x, y, 0, 1, 1, 8, 16)
useful.pushCanvas(SHADOW_CANVAS)
useful.bindBlack()
useful.oval("fill", self.x, self.y, 8, 8*VIEW_OBLIQUE)
useful.bindWhite()
useful.popCanvas()
end
--[[------------------------------------------------------------
Collisions
--]]--
function Food:eventCollision(other, dt)
if other:isType("Food") or other:isType("Building") then
self:shoveAwayFrom(other, 100*dt)
end
end
--[[------------------------------------------------------------
Export
--]]--
return Food |
AddCSLuaFile()
SWEP.HoldType = "normal"
if CLIENT then
SWEP.PrintName = "binoc_name"
SWEP.Slot = 7
SWEP.ViewModelFOV = 10
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "binoc_desc"
};
SWEP.Icon = "vgui/ttt/icon_binoc"
end
SWEP.Base = "weapon_tttbase"
SWEP.ViewModel = "models/weapons/v_crowbar.mdl"
SWEP.WorldModel = "models/props/cs_office/paper_towels.mdl"
SWEP.DrawCrosshair = false
SWEP.ViewModelFlip = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 1.0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 0.2
SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_DETECTIVE} -- only detectives can buy
SWEP.WeaponID = AMMO_BINOCULARS
SWEP.AllowDrop = true
SWEP.ZoomLevels = {
0,
30,
20,
10
};
SWEP.ProcessingDelay = 5
function SWEP:SetupDataTables()
self:DTVar("Bool", 0, "processing")
self:DTVar("Float", 0, "start_time")
self:DTVar("Int", 1, "zoom")
return self.BaseClass.SetupDataTables(self)
end
function SWEP:PrimaryAttack()
self:SetNextPrimaryFire( CurTime() + 0.1 )
if self:IsTargetingCorpse() and not self.dt.processing then
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
if SERVER then
self.dt.processing = true
self.dt.start_time = CurTime()
end
end
end
local click = Sound("weapons/sniper/sniper_zoomin.wav")
function SWEP:SecondaryAttack()
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
if CLIENT and IsFirstTimePredicted() then
LocalPlayer():EmitSound(click)
end
self:CycleZoom()
self.dt.processing = false
self.dt.start_time = 0
end
function SWEP:SetZoom(level)
if SERVER then
self.dt.zoom = level
self.Owner:SetFOV(self.ZoomLevels[level], 0.3)
self.Owner:DrawViewModel(false)
end
end
function SWEP:CycleZoom()
self.dt.zoom = self.dt.zoom + 1
if not self.ZoomLevels[self.dt.zoom] then
self.dt.zoom = 1
end
self:SetZoom(self.dt.zoom)
end
function SWEP:PreDrop()
self:SetZoom(1)
self.dt.processing = false
return self.BaseClass.PreDrop(self)
end
function SWEP:Holster()
self:SetZoom(1)
self.dt.processing = false
return true
end
function SWEP:Deploy()
if SERVER and IsValid(self.Owner) then
self.Owner:DrawViewModel(false)
end
return true
end
function SWEP:Reload()
return false
end
function SWEP:IsTargetingCorpse()
local tr = self.Owner:GetEyeTrace(MASK_SHOT)
local ent = tr.Entity
return (IsValid(ent) and ent:GetClass() == "prop_ragdoll" and
CORPSE.GetPlayerNick(ent, false) != false)
end
local confirm = Sound("npc/turret_floor/click1.wav")
function SWEP:IdentifyCorpse()
if SERVER then
local tr = self.Owner:GetEyeTrace(MASK_SHOT)
CORPSE.ShowSearch(self.Owner, tr.Entity, false, true)
elseif IsFirstTimePredicted() then
LocalPlayer():EmitSound(confirm)
end
end
function SWEP:Think()
if self.dt.processing then
if self:IsTargetingCorpse() then
if CurTime() > (self.dt.start_time + self.ProcessingDelay) then
self:IdentifyCorpse()
self.dt.processing = false
self.dt.start_time = 0
end
else
self.dt.processing = false
self.dt.start_time = 0
end
end
end
function SWEP:OnRemove()
if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
RunConsoleCommand("lastinv")
end
end
if CLIENT then
function SWEP:Initialize()
self:AddHUDHelp("binoc_help_pri", "binoc_help_sec", true)
return self.BaseClass.Initialize(self)
end
function SWEP:DrawHUD()
self:DrawHelp()
local length = 40
local gap = 10
local corpse = self:IsTargetingCorpse()
if corpse then
surface.SetDrawColor(0, 255, 0, 255)
gap = 4
length = 40
else
surface.SetDrawColor(0, 255, 0, 200)
end
local x = ScrW() / 2.0
local y = ScrH() / 2.0
surface.DrawLine( x - length, y, x - gap, y )
surface.DrawLine( x + length, y, x + gap, y )
surface.DrawLine( x, y - length, x, y - gap )
surface.DrawLine( x, y + length, x, y + gap )
surface.SetFont("DefaultFixedDropShadow")
surface.SetTextColor(0, 255, 0, 200)
surface.SetTextPos( x + length, y - length )
surface.DrawText("LEVEL " .. self.dt.zoom)
if corpse then
surface.SetTextPos( x + length, y - length + 15)
surface.DrawText("BODY DETECTED")
end
if self.dt.processing then
y = y + (y / 2)
local w, h = 200, 20
surface.SetDrawColor(0, 255, 0, 255)
surface.DrawOutlinedRect(x - w/2, y - h, w, h)
surface.SetDrawColor(0, 255, 0, 180)
local pct = math.Clamp((CurTime() - self.dt.start_time) / self.ProcessingDelay, 0, 1)
surface.DrawRect(x - w/2, y - h, w * pct, h)
end
end
function SWEP:DrawWorldModel()
if not IsValid(self.Owner) then
self:DrawModel()
end
end
function SWEP:AdjustMouseSensitivity()
if self.dt.zoom > 0 then
return 1 / self.dt.zoom
end
return -1
end
end
|
object_building_kashyyyk_shrb_beach_root_cup_cluster = object_building_kashyyyk_shared_shrb_beach_root_cup_cluster:new {
}
ObjectTemplates:addTemplate(object_building_kashyyyk_shrb_beach_root_cup_cluster, "object/building/kashyyyk/shrb_beach_root_cup_cluster.iff")
|
newaction
{
trigger = "raw",
shortname = "Raw output",
description = "Generate raw representation of Premake structures",
onsolution = function(sln)
require('raw')
premake.generate(sln, ".raw", premake.raw.workspace)
end,
}
return function(cfg)
return (_ACTION == "raw")
end
|
local Part={}
function Part:new(o)
o=o or {}
setmetatable(o,self)
self.__index=self
o.swing = o.swing or 50
o.enabled = o.enabled==nil and true or o.enabled
o.stroke = o.stroke or 1
o.note = o.note or 9
o.count = o.count or 1
o.interval = o.interval or 0
o.s=nil
return o
end
function Part:dump()
local t={}
local to_dump={"swing","enabled","stroke","note","count","interval"}
for _, k in ipairs(to_dump) do
t[k]=self[k]
end
return json.encode(t)
end
function Part:load(s)
local d=json.decode(s)
if d==nil then
do return end
end
for k,v in pairs(d) do
self[k]=v
end
end
function Part:get_stroke()
return mallet_strokes[self.stroke]
end
function Part:get_count()
return self.count
end
function Part:get_notes()
local t
t={self.note}
if self.interval>0 then
table.insert(t,self.note+self.interval)
end
return t
end
function Part:seq()
local t={}
for i=1,self.count do
local stroke=mallet_strokes[self.stroke]
for j=1, #stroke do
local c = stroke:sub(j,j)
local notes={}
table.insert(notes,self.note)
if self.interval > 0 and self.note+self.interval <= 17 then
table.insert(notes,self.note+self.interval)
end
table.insert(t,{n=notes,r=c})
end
end
return t
end
return Part
|
--------------------------------------------------------------------
------- this file in auto generate by the bind3D -------------------
------- https://github.com/xtoolbox/pcad2kicad -------------------
--------------------------------------------------------------------
fpTable = {
{
name = "0201",
path = "X:/lc_kicad_lib/lc_lib.pretty/0201.kicad_mod",
rotate = "0",
key = "0201",
fp = "C_0201",
},
{
name = "0201_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/0201_C.kicad_mod",
rotate = "0",
key = "0201 ,C",
fp = "C_0201",
},
{
name = "0201_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/0201_L.kicad_mod",
rotate = "0",
key = "0201 ,L",
fp = "L_0201",
},
{
name = "0201_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/0201_R.kicad_mod",
rotate = "0",
key = "0201 ,R",
fp = "R_0201",
},
{
name = "0402",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402.kicad_mod",
rotate = "0",
key = "0402",
fp = "C_0402",
},
{
name = "0402_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402_C.kicad_mod",
rotate = "0",
key = "0402 ,C",
fp = "C_0402",
},
{
name = "0402_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402_L.kicad_mod",
rotate = "0",
key = "0402 ,L",
fp = "L_0402",
},
{
name = "0402_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402_R.kicad_mod",
rotate = "0",
key = "0402 ,R",
fp = "R_0402",
},
{
name = "0402_RX2",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402_RX2.kicad_mod",
rotate = "-90",
key = "0402 ,2X ,ARRAY ,RX2",
fp = "R_Array_Convex_2x0402",
},
{
name = "0402_RX4",
path = "X:/lc_kicad_lib/lc_lib.pretty/0402_RX4.kicad_mod",
rotate = "-90",
key = "0402 ,4X ,ARRAY ,RX4",
fp = "R_Array_Concave_4x0402",
},
{
name = "0603",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603.kicad_mod",
rotate = "0",
key = "0603",
fp = "C_0603",
},
{
name = "0603_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_C.kicad_mod",
rotate = "0",
key = "0603 ,C",
fp = "C_0603",
},
{
name = "0603_CX4",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_CX4.kicad_mod",
rotate = "-90",
key = "0603 ,4X ,ARRAY ,CX4",
fp = "R_Array_Concave_4x0603",
},
{
name = "0603_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_L.kicad_mod",
rotate = "0",
key = "0603 ,L",
fp = "L_0603",
},
{
name = "0603_LED_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_LED_S1.kicad_mod",
rotate = "0",
key = "0603 ,LED ,S1",
fp = "LED_0603",
},
{
name = "0603_LED_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_LED_S2.kicad_mod",
rotate = "0",
key = "0603 ,LED ,S2",
fp = "LED_0603",
},
{
name = "0603_LED_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_LED_S3.kicad_mod",
rotate = "0",
key = "0603 ,LED ,S3",
fp = "LED_0603",
},
{
name = "0603_LED_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_LED_S4.kicad_mod",
rotate = "0",
key = "0603 ,LED ,S4",
fp = "LED_0603",
},
{
name = "0603_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_R.kicad_mod",
rotate = "0",
key = "0603 ,R",
fp = "R_0603",
},
{
name = "0603_RX2",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_RX2.kicad_mod",
rotate = "-90",
key = "0603 ,2X ,ARRAY ,RX2",
fp = "R_Array_Concave_2x0603",
},
{
name = "0603_RX4",
path = "X:/lc_kicad_lib/lc_lib.pretty/0603_RX4.kicad_mod",
rotate = "-90",
key = "0603 ,4X ,ARRAY ,RX4",
fp = "R_Array_Concave_4x0603",
},
{
name = "0805",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805.kicad_mod",
rotate = "0",
key = "0805",
fp = "C_0805",
},
{
name = "0805_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_C.kicad_mod",
rotate = "0",
key = "0805 ,C",
fp = "C_0805",
},
{
name = "0805_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_L.kicad_mod",
rotate = "0",
key = "0805 ,L",
fp = "L_0805",
},
{
name = "0805_LED_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_LED_S1.kicad_mod",
rotate = "0",
key = "0805 ,LED ,S1",
fp = "LED_0805",
},
{
name = "0805_LED_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_LED_S2.kicad_mod",
rotate = "0",
key = "0805 ,LED ,S2",
fp = "LED_0805",
},
{
name = "0805_LED_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_LED_S3.kicad_mod",
rotate = "0",
key = "0805 ,LED ,S3",
fp = "LED_0805",
},
{
name = "0805_LED_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_LED_S4.kicad_mod",
rotate = "0",
key = "0805 ,LED ,S4",
fp = "LED_0805",
},
{
name = "0805_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/0805_R.kicad_mod",
rotate = "0",
key = "0805 ,R",
fp = "R_0805",
},
{
name = "1206",
path = "X:/lc_kicad_lib/lc_lib.pretty/1206.kicad_mod",
rotate = "0",
key = "1206",
fp = "C_1206",
},
{
name = "1206_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1206_C.kicad_mod",
rotate = "0",
key = "1206 ,C",
fp = "C_1206",
},
{
name = "1206_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/1206_L.kicad_mod",
rotate = "0",
key = "1206 ,L",
fp = "L_1206",
},
{
name = "1206_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1206_R.kicad_mod",
rotate = "0",
key = "1206 ,R",
fp = "R_1206",
},
{
name = "1210",
path = "X:/lc_kicad_lib/lc_lib.pretty/1210.kicad_mod",
rotate = "0",
key = "1210",
fp = "C_1210",
},
{
name = "1210_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1210_C.kicad_mod",
rotate = "0",
key = "1210 ,C",
fp = "C_1210",
},
{
name = "1210_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1210_R.kicad_mod",
rotate = "0",
key = "1210 ,R",
fp = "R_1210",
},
{
name = "1806",
path = "X:/lc_kicad_lib/lc_lib.pretty/1806.kicad_mod",
rotate = "0",
key = "1806",
fp = "C_1806_4516Metric",
},
{
name = "1806_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1806_C.kicad_mod",
rotate = "0",
key = "1806 ,C",
fp = "C_1806_4516Metric",
},
{
name = "1806_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/1806_L.kicad_mod",
rotate = "0",
key = "1806 ,L",
fp = "L_1806",
},
{
name = "1806_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1806_R.kicad_mod",
rotate = "0",
key = "1806 ,R",
fp = "R_1806_4516Metric",
},
{
name = "1808",
path = "X:/lc_kicad_lib/lc_lib.pretty/1808.kicad_mod",
rotate = "0",
key = "1808",
fp = "",
},
{
name = "1808_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1808_C.kicad_mod",
rotate = "0",
key = "1808 ,C",
fp = "",
},
{
name = "1808_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/1808_L.kicad_mod",
rotate = "0",
key = "1808 ,L",
fp = "",
},
{
name = "1808_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1808_R.kicad_mod",
rotate = "0",
key = "1808 ,R",
fp = "",
},
{
name = "1812",
path = "X:/lc_kicad_lib/lc_lib.pretty/1812.kicad_mod",
rotate = "0",
key = "1812",
fp = "C_1812",
},
{
name = "1812_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1812_C.kicad_mod",
rotate = "0",
key = "1812 ,C",
fp = "C_1812",
},
{
name = "1812_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/1812_L.kicad_mod",
rotate = "0",
key = "1812 ,L",
fp = "L_1812",
},
{
name = "1812_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1812_R.kicad_mod",
rotate = "0",
key = "1812 ,R",
fp = "R_1812",
},
{
name = "1825",
path = "X:/lc_kicad_lib/lc_lib.pretty/1825.kicad_mod",
rotate = "0",
key = "1825",
fp = "C_1825",
},
{
name = "1825_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/1825_C.kicad_mod",
rotate = "0",
key = "1825 ,C",
fp = "C_1825",
},
{
name = "1825_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/1825_L.kicad_mod",
rotate = "0",
key = "1825 ,L",
fp = "C_1825",
},
{
name = "1825_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/1825_R.kicad_mod",
rotate = "0",
key = "1825 ,R",
fp = "C_1825",
},
{
name = "2010",
path = "X:/lc_kicad_lib/lc_lib.pretty/2010.kicad_mod",
rotate = "0",
key = "2010",
fp = "C_2010_5025Metric",
},
{
name = "2010_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/2010_C.kicad_mod",
rotate = "0",
key = "2010 ,C",
fp = "C_2010_5025Metric",
},
{
name = "2010_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/2010_L.kicad_mod",
rotate = "0",
key = "2010 ,L",
fp = "L_2010_5025Metric",
},
{
name = "2010_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/2010_R.kicad_mod",
rotate = "0",
key = "2010 ,R",
fp = "R_2010",
},
{
name = "2220",
path = "X:/lc_kicad_lib/lc_lib.pretty/2220.kicad_mod",
rotate = "0",
key = "2220",
fp = "C_2220",
},
{
name = "2220_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/2220_C.kicad_mod",
rotate = "0",
key = "2220 ,C",
fp = "C_2220",
},
{
name = "2220_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/2220_L.kicad_mod",
rotate = "0",
key = "2220 ,L",
fp = "C_2220",
},
{
name = "2220_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/2220_R.kicad_mod",
rotate = "0",
key = "2220 ,R",
fp = "C_2220",
},
{
name = "2225",
path = "X:/lc_kicad_lib/lc_lib.pretty/2225.kicad_mod",
rotate = "0",
key = "2225",
fp = "C_2225",
},
{
name = "2225_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/2225_C.kicad_mod",
rotate = "0",
key = "2225 ,C",
fp = "C_2225",
},
{
name = "2225_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/2225_R.kicad_mod",
rotate = "0",
key = "2225 ,R",
fp = "C_2225",
},
{
name = "2512",
path = "X:/lc_kicad_lib/lc_lib.pretty/2512.kicad_mod",
rotate = "0",
key = "2512",
fp = "C_2512_6332Metric",
},
{
name = "2512_C",
path = "X:/lc_kicad_lib/lc_lib.pretty/2512_C.kicad_mod",
rotate = "0",
key = "2512 ,C",
fp = "C_2512_6332Metric",
},
{
name = "2512_L",
path = "X:/lc_kicad_lib/lc_lib.pretty/2512_L.kicad_mod",
rotate = "0",
key = "2512 ,L",
fp = "L_2512_6332Metric",
},
{
name = "2512_R",
path = "X:/lc_kicad_lib/lc_lib.pretty/2512_R.kicad_mod",
rotate = "0",
key = "2512 ,R",
fp = "R_2512",
},
{
name = "ABS",
path = "X:/lc_kicad_lib/lc_lib.pretty/ABS.kicad_mod",
rotate = "180",
key = "ABS",
fp = "Diode_Bridge_Diotec_ABS",
},
{
name = "BGA-121",
path = "X:/lc_kicad_lib/lc_lib.pretty/BGA-121.kicad_mod",
rotate = "-90",
key = "BGA-121",
fp = "BGA-121_12.0x12.0mm_Layout11x11_P1.0mm",
},
{
name = "BGA-14",
path = "X:/lc_kicad_lib/lc_lib.pretty/BGA-14.kicad_mod",
rotate = "-90",
key = "BGA-14",
fp = "",
},
{
name = "BGA-143",
path = "X:/lc_kicad_lib/lc_lib.pretty/BGA-143.kicad_mod",
rotate = "-90",
key = "BGA-143",
fp = "",
},
{
name = "BGA-84_7.5X12.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/BGA-84_7.5X12.5MM.kicad_mod",
rotate = "-90",
key = "BGA-84 ,7.5X12.5MM",
fp = "",
},
{
name = "BR-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/BR-10.kicad_mod",
rotate = "90",
key = "BR-10",
fp = "",
},
{
name = "BR-3",
path = "X:/lc_kicad_lib/lc_lib.pretty/BR-3.kicad_mod",
rotate = "-90",
key = "BR-3",
fp = "",
},
{
name = "BR-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/BR-6.kicad_mod",
rotate = "90",
key = "BR-6",
fp = "",
},
{
name = "CASE-017AA-01",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-017AA-01.kicad_mod",
rotate = "180",
key = "CASE-017AA-01",
fp = "",
},
{
name = "CASE-A_3216",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-A_3216.kicad_mod",
rotate = "180",
key = "CASE-A ,3216",
fp = "CP_Tantalum_Case-A_EIA-3216-18",
},
{
name = "CASE-B_3528",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-B_3528.kicad_mod",
rotate = "180",
key = "CASE-B ,3528",
fp = "CP_Tantalum_Case-B_EIA-3528-21",
},
{
name = "CASE-C_6032",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-C_6032.kicad_mod",
rotate = "180",
key = "CASE-C ,6032",
fp = "CP_Tantalum_Case-C_EIA-6032-28",
},
{
name = "CASE-D_7343",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-D_7343.kicad_mod",
rotate = "180",
key = "CASE-D ,7343",
fp = "CP_Tantalum_Case-D_EIA-7343-31",
},
{
name = "CASE-E_7343",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-E_7343.kicad_mod",
rotate = "180",
key = "CASE-E ,7343",
fp = "CP_Tantalum_Case-E_EIA-7260-38",
},
{
name = "CASE-P_2012",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-P_2012.kicad_mod",
rotate = "180",
key = "CASE-P ,2012",
fp = "",
},
{
name = "CASE-R_2012",
path = "X:/lc_kicad_lib/lc_lib.pretty/CASE-R_2012.kicad_mod",
rotate = "180",
key = "CASE-R ,2012",
fp = "CP_Tantalum_Case-R_EIA-2012-12",
},
{
name = "CSP2-28_OV7725",
path = "X:/lc_kicad_lib/lc_lib.pretty/CSP2-28_OV7725.kicad_mod",
rotate = "0",
key = "2P ,CSP2-28 ,OV7725",
fp = "",
},
{
name = "CSP2-28_OV9712",
path = "X:/lc_kicad_lib/lc_lib.pretty/CSP2-28_OV9712.kicad_mod",
rotate = "0",
key = "2P ,CSP2-28 ,OV9712",
fp = "",
},
{
name = "DB",
path = "X:/lc_kicad_lib/lc_lib.pretty/DB.kicad_mod",
rotate = "180",
key = "DB",
fp = "",
},
{
name = "DBS",
path = "X:/lc_kicad_lib/lc_lib.pretty/DBS.kicad_mod",
rotate = "180",
key = "DBS",
fp = "",
},
{
name = "DBS7P",
path = "X:/lc_kicad_lib/lc_lib.pretty/DBS7P.kicad_mod",
rotate = "-90",
key = "7P ,DBS7P",
fp = "",
},
{
name = "DBS9MPF",
path = "X:/lc_kicad_lib/lc_lib.pretty/DBS9MPF.kicad_mod",
rotate = "-90",
key = "DBS9MPF",
fp = "",
},
{
name = "DFN-10_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-10_3X3MM.kicad_mod",
rotate = "-90",
key = "DFN-10 ,3X3MM",
fp = "DFN-10-1EP_3x3mm_P0.5mm_EP1.55x2.48mm",
},
{
name = "DFN-10_EP_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-10_EP_3X3MM.kicad_mod",
rotate = "-90",
key = "DFN-10 ,EP ,3X3MM",
fp = "DFN-10-1EP_2x3mm_P0.5mm_EP0.64x2.4mm",
},
{
name = "DFN-2L",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-2L.kicad_mod",
rotate = "180",
key = "DFN-2L",
fp = "",
},
{
name = "DFN-8_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-8_3X3MM.kicad_mod",
rotate = "-90",
key = "DFN-8 ,3X3MM",
fp = "DFN-8-1EP_3x3mm_P0.5mm_EP1.66x2.38mm",
},
{
name = "DFN-8_5X6MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-8_5X6MM.kicad_mod",
rotate = "-90",
key = "DFN-8 ,5X6MM",
fp = "DFN-8-1EP_2x2mm_P0.45mm_EP0.64x1.38mm",
},
{
name = "DFN-8_EP_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/DFN-8_EP_3X3MM.kicad_mod",
rotate = "-90",
key = "DFN-8 ,EP ,3X3MM",
fp = "DFN-8-1EP_2x2mm_P0.45mm_EP0.64x1.38mm",
},
{
name = "DIP-12H",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-12H.kicad_mod",
rotate = "0",
key = "DIP-12H",
fp = "",
},
{
name = "DIP-14",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-14.kicad_mod",
rotate = "0",
key = "DIP-14",
fp = "DIP-14_W7.62mm",
},
{
name = "DIP-16",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-16.kicad_mod",
rotate = "0",
key = "DIP-16",
fp = "DIP-16_W7.62mm",
},
{
name = "DIP-18",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-18.kicad_mod",
rotate = "0",
key = "DIP-18",
fp = "DIP-18_W7.62mm",
},
{
name = "DIP-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-20.kicad_mod",
rotate = "0",
key = "DIP-20",
fp = "DIP-20_W7.62mm",
},
{
name = "DIP-24_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-24_300MIL.kicad_mod",
rotate = "0",
key = "DIP-24 ,300MIL",
fp = "DIP-24_W10.16mm",
},
{
name = "DIP-24_600MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-24_600MIL.kicad_mod",
rotate = "0",
key = "DIP-24 ,600MIL",
fp = "DIP-24_W10.16mm",
},
{
name = "DIP-28_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-28_300MIL.kicad_mod",
rotate = "0",
key = "DIP-28 ,300MIL",
fp = "DIP-28_W15.24mm",
},
{
name = "DIP-28_600MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-28_600MIL.kicad_mod",
rotate = "0",
key = "DIP-28 ,600MIL",
fp = "DIP-28_W15.24mm",
},
{
name = "DIP-4",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-4.kicad_mod",
rotate = "0",
key = "DIP-4",
fp = "DIP-4_W10.16mm",
},
{
name = "DIP-40",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-40.kicad_mod",
rotate = "0",
key = "DIP-40",
fp = "DIP-40_W15.24mm",
},
{
name = "DIP-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-5.kicad_mod",
rotate = "0",
key = "DIP-5",
fp = "",
},
{
name = "DIP-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-6.kicad_mod",
rotate = "0",
key = "DIP-6",
fp = "DIP-6_W10.16mm",
},
{
name = "DIP-7",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-7.kicad_mod",
rotate = "0",
key = "DIP-7",
fp = "",
},
{
name = "DIP-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/DIP-8.kicad_mod",
rotate = "0",
key = "DIP-8",
fp = "DIP-8_SMD",
},
{
name = "DO-15",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-15.kicad_mod",
rotate = "180",
key = "DO-15",
fp = "D_DO-15_P10.16mm_Horizontal",
},
{
name = "DO-201AD",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-201AD.kicad_mod",
rotate = "180",
key = "DO-201AD",
fp = "D_DO-201AD_P12.70mm_Horizontal",
},
{
name = "DO-213AA",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-213AA.kicad_mod",
rotate = "180",
key = "DO-213AA",
fp = "",
},
{
name = "DO-213AB",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-213AB.kicad_mod",
rotate = "180",
key = "DO-213AB",
fp = "",
},
{
name = "DO-218",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-218.kicad_mod",
rotate = "0",
key = "DO-218",
fp = "",
},
{
name = "DO-27",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-27.kicad_mod",
rotate = "180",
key = "DO-27",
fp = "D_DO-27_P12.70mm_Horizontal",
},
{
name = "DO-35",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-35.kicad_mod",
rotate = "180",
key = "DO-35",
fp = "DO-35",
},
{
name = "DO-41",
path = "X:/lc_kicad_lib/lc_lib.pretty/DO-41.kicad_mod",
rotate = "180",
key = "DO-41",
fp = "D_DO-41_SOD81_P10.16mm_Horizontal",
},
{
name = "DSON-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/DSON-10.kicad_mod",
rotate = "-90",
key = "DSON-10",
fp = "",
},
{
name = "FBGA-256",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-256.kicad_mod",
rotate = "-90",
key = "FBGA-256",
fp = "",
},
{
name = "FBGA-272",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-272.kicad_mod",
rotate = "-90",
key = "FBGA-272",
fp = "",
},
{
name = "FBGA-289",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-289.kicad_mod",
rotate = "-90",
key = "FBGA-289",
fp = "",
},
{
name = "FBGA-484",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-484.kicad_mod",
rotate = "-90",
key = "FBGA-484",
fp = "",
},
{
name = "FBGA-780",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-780.kicad_mod",
rotate = "-90",
key = "FBGA-780",
fp = "",
},
{
name = "FBGA-84_9X12.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-84_9X12.5MM.kicad_mod",
rotate = "-90",
key = "FBGA-84 ,9X12.5MM",
fp = "",
},
{
name = "FBGA-96_8X14MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/FBGA-96_8X14MM.kicad_mod",
rotate = "-90",
key = "FBGA-96 ,8X14MM",
fp = "",
},
{
name = "FLEXIWATT25",
path = "X:/lc_kicad_lib/lc_lib.pretty/FLEXIWATT25.kicad_mod",
rotate = "0",
key = "FLEXIWATT25",
fp = "",
},
{
name = "GBJ",
path = "X:/lc_kicad_lib/lc_lib.pretty/GBJ.kicad_mod",
rotate = "180",
key = "GBJ",
fp = "",
},
{
name = "GBU",
path = "X:/lc_kicad_lib/lc_lib.pretty/GBU.kicad_mod",
rotate = "0",
key = "GBU",
fp = "Diode_Bridge_Vishay_GBU",
},
{
name = "GDTS_SMD",
path = "X:/lc_kicad_lib/lc_lib.pretty/GDTS_SMD.kicad_mod",
rotate = "0",
key = "GDTS ,SMD",
fp = "",
},
{
name = "GDTS_THT",
path = "X:/lc_kicad_lib/lc_lib.pretty/GDTS_THT.kicad_mod",
rotate = "0",
key = "GDTS ,THT",
fp = "",
},
{
name = "HC-49S",
path = "X:/lc_kicad_lib/lc_lib.pretty/HC-49S.kicad_mod",
rotate = "0",
key = "HC-49S",
fp = "",
},
{
name = "HC-49SMD",
path = "X:/lc_kicad_lib/lc_lib.pretty/HC-49SMD.kicad_mod",
rotate = "0",
key = "HC-49SMD",
fp = "",
},
{
name = "HC-49U",
path = "X:/lc_kicad_lib/lc_lib.pretty/HC-49U.kicad_mod",
rotate = "0",
key = "HC-49U",
fp = "",
},
{
name = "HSOP-16",
path = "X:/lc_kicad_lib/lc_lib.pretty/HSOP-16.kicad_mod",
rotate = "-90",
key = "HSOP-16",
fp = "",
},
{
name = "HSOP-28-375-0.8",
path = "X:/lc_kicad_lib/lc_lib.pretty/HSOP-28-375-0.8.kicad_mod",
rotate = "-90",
key = "HSOP-28-375-0.8",
fp = "",
},
{
name = "HSOP-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/HSOP-8.kicad_mod",
rotate = "-90",
key = "HSOP-8",
fp = "",
},
{
name = "HTSSOP-14",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-14.kicad_mod",
rotate = "-90",
key = "HTSSOP-14",
fp = "",
},
{
name = "HTSSOP-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-20.kicad_mod",
rotate = "-90",
key = "HTSSOP-20",
fp = "HTSSOP-20-1EP_4.4x6.5mm_P0.65mm_EP3.4x6.5mm",
},
{
name = "HTSSOP-24",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-24.kicad_mod",
rotate = "-90",
key = "HTSSOP-24",
fp = "",
},
{
name = "HTSSOP-28",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-28.kicad_mod",
rotate = "-90",
key = "HTSSOP-28",
fp = "HTSSOP-28-1EP_4.4x9.7mm_P0.65mm_EP3.4x9.5mm",
},
{
name = "HTSSOP-32",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-32.kicad_mod",
rotate = "-90",
key = "HTSSOP-32",
fp = "",
},
{
name = "HTSSOP-38",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-38.kicad_mod",
rotate = "-90",
key = "HTSSOP-38",
fp = "",
},
{
name = "HTSSOP-B40",
path = "X:/lc_kicad_lib/lc_lib.pretty/HTSSOP-B40.kicad_mod",
rotate = "-90",
key = "HTSSOP-B40",
fp = "",
},
{
name = "HVMDIP-4",
path = "X:/lc_kicad_lib/lc_lib.pretty/HVMDIP-4.kicad_mod",
rotate = "-90",
key = "HVMDIP-4",
fp = "",
},
{
name = "HVQFN-32_5X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/HVQFN-32_5X5X05P.kicad_mod",
rotate = "-90",
key = "VQFN-32 ,HVQFN-32 ,05P ,5X5X05P",
fp = "",
},
{
name = "HZIP25-P-1.00F",
path = "X:/lc_kicad_lib/lc_lib.pretty/HZIP25-P-1.00F.kicad_mod",
rotate = "0",
key = "25P ,HZIP25-P-1.00F",
fp = "DFN-8-1EP_4x4mm_P0.8mm_EP2.5x3.6mm",
},
{
name = "HZIP25-P-1.27",
path = "X:/lc_kicad_lib/lc_lib.pretty/HZIP25-P-1.27.kicad_mod",
rotate = "0",
key = "25P ,HZIP25-P-1.27",
fp = "DFN-8-1EP_4x4mm_P0.8mm_EP2.5x3.6mm",
},
{
name = "KBJ",
path = "X:/lc_kicad_lib/lc_lib.pretty/KBJ.kicad_mod",
rotate = "180",
key = "KBJ",
fp = "",
},
{
name = "KBL",
path = "X:/lc_kicad_lib/lc_lib.pretty/KBL.kicad_mod",
rotate = "0",
key = "KBL",
fp = "Diode_Bridge_Vishay_KBL",
},
{
name = "KBP",
path = "X:/lc_kicad_lib/lc_lib.pretty/KBP.kicad_mod",
rotate = "0",
key = "KBP",
fp = "Diode_Bridge_Vishay_KBPC1",
},
{
name = "KBPC",
path = "X:/lc_kicad_lib/lc_lib.pretty/KBPC.kicad_mod",
rotate = "-90",
key = "KBPC",
fp = "Diode_Bridge_Vishay_KBPC1",
},
{
name = "KBU",
path = "X:/lc_kicad_lib/lc_lib.pretty/KBU.kicad_mod",
rotate = "0",
key = "KBU",
fp = "Diode_Bridge_Vishay_KBU",
},
{
name = "LBS",
path = "X:/lc_kicad_lib/lc_lib.pretty/LBS.kicad_mod",
rotate = "180",
key = "LBS",
fp = "",
},
{
name = "LFBGA-217",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFBGA-217.kicad_mod",
rotate = "-90",
key = "LFBGA-217",
fp = "",
},
{
name = "LFCSP-16_4X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-16_4X4X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-16 ,05P ,4X4X05P",
fp = "",
},
{
name = "LFCSP-20_4X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-20_4X4X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-20 ,05P ,4X4X05P",
fp = "",
},
{
name = "LFCSP-24_4X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-24_4X4X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-24 ,05P ,4X4X05P",
fp = "",
},
{
name = "LFCSP-28_5X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-28_5X5X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-28 ,05P ,5X5X05P",
fp = "",
},
{
name = "LFCSP-40_6X6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-40_6X6X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-40 ,05P ,6X6X05P",
fp = "LFCSP-40-1EP",
},
{
name = "LFCSP-56_8X8X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-56_8X8X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-56 ,05P ,8X8X05P",
fp = "",
},
{
name = "LFCSP-8_3X2X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-8_3X2X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-8 ,05P ,3X2X05P",
fp = "",
},
{
name = "LFCSP-8_3X3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LFCSP-8_3X3X05P.kicad_mod",
rotate = "-90",
key = "LFCSP-8 ,05P ,3X3X05P",
fp = "",
},
{
name = "LGA-14_3X5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/LGA-14_3X5MM.kicad_mod",
rotate = "-90",
key = "LGA-14 ,3X5MM",
fp = "",
},
{
name = "LGA-16_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/LGA-16_3X3MM.kicad_mod",
rotate = "-90",
key = "LGA-16 ,3X3MM",
fp = "",
},
{
name = "LGA-16_4X4MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/LGA-16_4X4MM.kicad_mod",
rotate = "-90",
key = "LGA-16 ,4X4MM",
fp = "",
},
{
name = "LGA-8_3X5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/LGA-8_3X5MM.kicad_mod",
rotate = "-90",
key = "LGA-8 ,3X5MM",
fp = "",
},
{
name = "LL-34",
path = "X:/lc_kicad_lib/lc_lib.pretty/LL-34.kicad_mod",
rotate = "180",
key = "LL-34",
fp = "",
},
{
name = "LL-35",
path = "X:/lc_kicad_lib/lc_lib.pretty/LL-35.kicad_mod",
rotate = "180",
key = "LL-35",
fp = "",
},
{
name = "LL-41",
path = "X:/lc_kicad_lib/lc_lib.pretty/LL-41.kicad_mod",
rotate = "180",
key = "LL-41",
fp = "",
},
{
name = "LPCC-148",
path = "X:/lc_kicad_lib/lc_lib.pretty/LPCC-148.kicad_mod",
rotate = "-90",
key = "LPCC-148",
fp = "",
},
{
name = "LQFP-100_14X14X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-100_14X14X05P.kicad_mod",
rotate = "-90",
key = "LQFP-100 ,05P ,14X14X05P",
fp = "LQFP-100_14x14mm_P0.5mm",
},
{
name = "LQFP-128_14X14X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-128_14X14X04P.kicad_mod",
rotate = "-90",
key = "LQFP-128 ,04P ,14X14X04P",
fp = "LQFP-128_14x14mm_P0.4mm",
},
{
name = "LQFP-144_20X20X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-144_20X20X05P.kicad_mod",
rotate = "-90",
key = "LQFP-144 ,05P ,20X20X05P",
fp = "LQFP-144_20x20mm_P0.5mm",
},
{
name = "LQFP-176_24X24X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-176_24X24X05P.kicad_mod",
rotate = "-90",
key = "LQFP-176 ,05P ,24X24X05P",
fp = "LQFP-176_24x24mm_P0.5mm",
},
{
name = "LQFP-208_28X28X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-208_28X28X05P.kicad_mod",
rotate = "-90",
key = "LQFP-208 ,05P ,28X28X05P",
fp = "LQFP-208_28x28mm_P0.5mm",
},
{
name = "LQFP-32_7X7X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-32_7X7X08P.kicad_mod",
rotate = "-90",
key = "LQFP-32 ,08P ,7X7X08P",
fp = "LQFP-32_7x7mm_P0.8mm",
},
{
name = "LQFP-44_10X10X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-44_10X10X08P.kicad_mod",
rotate = "-90",
key = "LQFP-44 ,08P ,10X10X08P",
fp = "LQFP-44_10x10mm_P0.8mm",
},
{
name = "LQFP-48_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-48_7X7X05P.kicad_mod",
rotate = "-90",
key = "LQFP-48 ,05P ,7X7X05P",
fp = "LQFP-48_7x7mm_P0.5mm",
},
{
name = "LQFP-64_10X10X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-64_10X10X05P.kicad_mod",
rotate = "-90",
key = "LQFP-64 ,05P ,10X10X05P",
fp = "LQFP-64-1EP_10x10mm_P0.5mm_EP6.5x6.5mm",
},
{
name = "LQFP-64_10X10X05P_Q2",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-64_10X10X05P_Q2.kicad_mod",
rotate = "0",
key = "LQFP-64 ,05P ,10X10X05P ,Q2",
fp = "LQFP-64-1EP_10x10mm_P0.5mm_EP6.5x6.5mm",
},
{
name = "LQFP-64_7X7X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-64_7X7X04P.kicad_mod",
rotate = "-90",
key = "LQFP-64 ,04P ,7X7X04P",
fp = "LQFP-64_7x7mm_P0.4mm",
},
{
name = "LQFP-80_10X10X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-80_10X10X04P.kicad_mod",
rotate = "-90",
key = "LQFP-80 ,04P ,10X10X04P",
fp = "LQFP-80_12x12mm_P0.5mm",
},
{
name = "LQFP-80_12X12X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-80_12X12X05P.kicad_mod",
rotate = "-90",
key = "LQFP-80 ,05P ,12X12X05P",
fp = "LQFP-80_12x12mm_P0.5mm",
},
{
name = "LQFP-80_14X14X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/LQFP-80_14X14X065P.kicad_mod",
rotate = "-90",
key = "LQFP-80 ,065P ,14X14X065P",
fp = "LQFP-80_12x12mm_P0.5mm",
},
{
name = "LSSOP-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/LSSOP-20.kicad_mod",
rotate = "-90",
key = "LSSOP-20",
fp = "",
},
{
name = "M04",
path = "X:/lc_kicad_lib/lc_lib.pretty/M04.kicad_mod",
rotate = "-90",
key = "M04",
fp = "",
},
{
name = "MBF",
path = "X:/lc_kicad_lib/lc_lib.pretty/MBF.kicad_mod",
rotate = "180",
key = "MBF",
fp = "",
},
{
name = "MBM",
path = "X:/lc_kicad_lib/lc_lib.pretty/MBM.kicad_mod",
rotate = "180",
key = "MBM",
fp = "",
},
{
name = "MBS",
path = "X:/lc_kicad_lib/lc_lib.pretty/MBS.kicad_mod",
rotate = "180",
key = "MBS",
fp = "",
},
{
name = "MFP10S",
path = "X:/lc_kicad_lib/lc_lib.pretty/MFP10S.kicad_mod",
rotate = "-90",
key = "10P ,MFP10S",
fp = "",
},
{
name = "MFP14S",
path = "X:/lc_kicad_lib/lc_lib.pretty/MFP14S.kicad_mod",
rotate = "-90",
key = "14P ,MFP14S",
fp = "",
},
{
name = "MFP30KR",
path = "X:/lc_kicad_lib/lc_lib.pretty/MFP30KR.kicad_mod",
rotate = "-90",
key = "30P ,MFP30KR",
fp = "",
},
{
name = "MICROFET_2X2",
path = "X:/lc_kicad_lib/lc_lib.pretty/MICROFET_2X2.kicad_mod",
rotate = "-90",
key = "MICROFET ,2X ,ARRAY ,2 ,2X2",
fp = "",
},
{
name = "MLPQ-48_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/MLPQ-48_7X7X05P.kicad_mod",
rotate = "-90",
key = "MLPQ-48 ,05P ,7X7X05P",
fp = "",
},
{
name = "MQFP-44_10X10X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/MQFP-44_10X10X08P.kicad_mod",
rotate = "-90",
key = "MQFP-44 ,08P ,10X10X08P",
fp = "",
},
{
name = "MQFP-52_10X10X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/MQFP-52_10X10X065P.kicad_mod",
rotate = "-90",
key = "MQFP-52 ,065P ,10X10X065P",
fp = "",
},
{
name = "MSOP-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/MSOP-10.kicad_mod",
rotate = "-90",
key = "MSOP-10",
fp = "MSOP-10-1EP_3x3mm_P0.5mm_EP1.68x1.88mm",
},
{
name = "MSOP-8-PP",
path = "X:/lc_kicad_lib/lc_lib.pretty/MSOP-8-PP.kicad_mod",
rotate = "-90",
key = "MSOP-8-PP",
fp = "",
},
{
name = "MSOP-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/MSOP-8.kicad_mod",
rotate = "-90",
key = "MSOP-8",
fp = "MSOP-8",
},
{
name = "MSOP-8_EP",
path = "X:/lc_kicad_lib/lc_lib.pretty/MSOP-8_EP.kicad_mod",
rotate = "-90",
key = "MSOP-8 ,EP",
fp = "MSOP-8-1EP_3x3mm_P0.65mm_EP1.68x1.88mm",
},
{
name = "MULTIWATT11V",
path = "X:/lc_kicad_lib/lc_lib.pretty/MULTIWATT11V.kicad_mod",
rotate = "-90",
key = "MULTIWATT11V",
fp = "",
},
{
name = "MULTIWATT15V",
path = "X:/lc_kicad_lib/lc_lib.pretty/MULTIWATT15V.kicad_mod",
rotate = "-90",
key = "MULTIWATT15V",
fp = "",
},
{
name = "NFBGA-139",
path = "X:/lc_kicad_lib/lc_lib.pretty/NFBGA-139.kicad_mod",
rotate = "-90",
key = "NFBGA-139",
fp = "",
},
{
name = "P600",
path = "X:/lc_kicad_lib/lc_lib.pretty/P600.kicad_mod",
rotate = "180",
key = "600P ,P600",
fp = "D_P600_R-6_P12.70mm_Horizontal",
},
{
name = "PG-TDSON-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/PG-TDSON-8.kicad_mod",
rotate = "-90",
key = "PG-TDSON-8",
fp = "",
},
{
name = "PLCC-28",
path = "X:/lc_kicad_lib/lc_lib.pretty/PLCC-28.kicad_mod",
rotate = "0",
key = "PLCC-28",
fp = "",
},
{
name = "PLCC-32",
path = "X:/lc_kicad_lib/lc_lib.pretty/PLCC-32.kicad_mod",
rotate = "0",
key = "PLCC-32",
fp = "",
},
{
name = "PLCC-44",
path = "X:/lc_kicad_lib/lc_lib.pretty/PLCC-44.kicad_mod",
rotate = "0",
key = "PLCC-44",
fp = "",
},
{
name = "PLCC-68",
path = "X:/lc_kicad_lib/lc_lib.pretty/PLCC-68.kicad_mod",
rotate = "0",
key = "PLCC-68",
fp = "PLCC68",
},
{
name = "PLOYZEN-SMD",
path = "X:/lc_kicad_lib/lc_lib.pretty/PLOYZEN-SMD.kicad_mod",
rotate = "0",
key = "PLOYZEN-SMD",
fp = "",
},
{
name = "POWERPAK-1212-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERPAK-1212-8.kicad_mod",
rotate = "-90",
key = "POWERPAK-1212-8",
fp = "",
},
{
name = "POWERPAK-SO-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERPAK-SO-8.kicad_mod",
rotate = "180",
key = "POWERPAK-SO-8",
fp = "",
},
{
name = "POWERSO-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERSO-10.kicad_mod",
rotate = "-90",
key = "POWERSO-10",
fp = "",
},
{
name = "POWERSO-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERSO-20.kicad_mod",
rotate = "-90",
key = "POWERSO-20",
fp = "PowerSO-20",
},
{
name = "POWERSO-36",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERSO-36.kicad_mod",
rotate = "-90",
key = "POWERSO-36",
fp = "",
},
{
name = "POWERSSO-24",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWERSSO-24.kicad_mod",
rotate = "-90",
key = "POWERSSO-24",
fp = "",
},
{
name = "POWER_56",
path = "X:/lc_kicad_lib/lc_lib.pretty/POWER_56.kicad_mod",
rotate = "-90",
key = "POWER ,56",
fp = "R_Axial_Power_L20.0mm_W6.4mm_P22.40mm",
},
{
name = "PQFN-12_3X3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFN-12_3X3X05P.kicad_mod",
rotate = "-90",
key = "PQFN-12 ,05P ,3X3X05P",
fp = "",
},
{
name = "PQFN_5X6MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFN_5X6MM.kicad_mod",
rotate = "-90",
key = "PQFN ,5X6MM",
fp = "",
},
{
name = "PQFP-128_20X14X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-128_20X14X05P.kicad_mod",
rotate = "-90",
key = "PQFP-128 ,05P ,20X14X05P",
fp = "",
},
{
name = "PQFP-144_20X20X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-144_20X20X05P.kicad_mod",
rotate = "-90",
key = "PQFP-144 ,05P ,20X20X05P",
fp = "",
},
{
name = "PQFP-160_28X28X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-160_28X28X065P.kicad_mod",
rotate = "-90",
key = "PQFP-160 ,065P ,28X28X065P",
fp = "PQFP-160",
},
{
name = "PQFP-208_28X28X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-208_28X28X05P.kicad_mod",
rotate = "-90",
key = "PQFP-208 ,05P ,28X28X05P",
fp = "PQFP-208",
},
{
name = "PQFP-240_32X32X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-240_32X32X05P.kicad_mod",
rotate = "-90",
key = "PQFP-240 ,05P ,32X32X05P",
fp = "",
},
{
name = "PQFP-256_40X28X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/PQFP-256_40X28X05P.kicad_mod",
rotate = "-90",
key = "PQFP-256 ,05P ,40X28X05P",
fp = "PQFP-256_28x28mm_P0.4mm",
},
{
name = "PSOP-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/PSOP-8.kicad_mod",
rotate = "-90",
key = "PSOP-8",
fp = "",
},
{
name = "QFN-10_3X3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-10_3X3X05P.kicad_mod",
rotate = "-90",
key = "QFN-10 ,05P ,3X3X05P",
fp = "",
},
{
name = "QFN-11_3X3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-11_3X3X05P.kicad_mod",
rotate = "-90",
key = "QFN-11 ,05P ,3X3X05P",
fp = "",
},
{
name = "QFN-14_3X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-14_3X4X05P.kicad_mod",
rotate = "-90",
key = "QFN-14 ,05P ,3X4X05P",
fp = "",
},
{
name = "QFN-16_3X3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-16_3X3X05P.kicad_mod",
rotate = "-90",
key = "QFN-16 ,05P ,3X3X05P",
fp = "QFN-16-1EP_3x3mm_P0.5mm_EP1.8x1.8mm",
},
{
name = "QFN-16_4X4X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-16_4X4X065P.kicad_mod",
rotate = "-90",
key = "QFN-16 ,065P ,4X4X065P",
fp = "QFN-16-1EP_4x4mm_P0.65mm_EP2.5x2.5mm",
},
{
name = "QFN-20_3.5X4.5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-20_3.5X4.5X05P.kicad_mod",
rotate = "-90",
key = "QFN-20 ,05P ,3.5X4.5X05P",
fp = "QFN-20-1EP_3x4mm_P0.5mm_EP1.65x2.65mm",
},
{
name = "QFN-20_3X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-20_3X4X05P.kicad_mod",
rotate = "-90",
key = "QFN-20 ,05P ,3X4X05P",
fp = "QFN-20-1EP_3x4mm_P0.5mm_EP1.65x2.65mm",
},
{
name = "QFN-20_4X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-20_4X4X05P.kicad_mod",
rotate = "-90",
key = "QFN-20 ,05P ,4X4X05P",
fp = "QFN-20-1EP_3x4mm_P0.5mm_EP1.65x2.65mm",
},
{
name = "QFN-22_3X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-22_3X4X05P.kicad_mod",
rotate = "-90",
key = "QFN-22 ,05P ,3X4X05P",
fp = "",
},
{
name = "QFN-24_4X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-24_4X4X05P.kicad_mod",
rotate = "-90",
key = "QFN-24 ,05P ,4X4X05P",
fp = "QFN-24-1EP_4x4mm_P0.5mm_EP2.6x2.6mm",
},
{
name = "QFN-26_4X4MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-26_4X4MM.kicad_mod",
rotate = "-90",
key = "QFN-26 ,4X4MM",
fp = "",
},
{
name = "QFN-28_5X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-28_5X5X05P.kicad_mod",
rotate = "-90",
key = "QFN-28 ,05P ,5X5X05P",
fp = "QFN-28-1EP_3x6mm_P0.5mm_EP1.7x4.75mm",
},
{
name = "QFN-28_6X6X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-28_6X6X065P.kicad_mod",
rotate = "-90",
key = "QFN-28 ,065P ,6X6X065P",
fp = "QFN-28-1EP_6x6mm_P0.65mm_EP4.25x4.25mm",
},
{
name = "QFN-32_5X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-32_5X5X05P.kicad_mod",
rotate = "-90",
key = "QFN-32 ,05P ,5X5X05P",
fp = "QFN-32-1EP_5x5mm_P0.5mm_EP3.45x3.45mm",
},
{
name = "QFN-32_7X7X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-32_7X7X065P.kicad_mod",
rotate = "-90",
key = "QFN-32 ,065P ,7X7X065P",
fp = "QFN-32-1EP_7x7mm_P0.65mm_EP5.46x5.46mm",
},
{
name = "QFN-36_6X6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-36_6X6X05P.kicad_mod",
rotate = "-90",
key = "QFN-36 ,05P ,6X6X05P",
fp = "QFN-36-1EP_5x6mm_P0.5mm_EP3.6x4.6mm",
},
{
name = "QFN-40_5X5X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-40_5X5X04P.kicad_mod",
rotate = "-90",
key = "QFN-40 ,04P ,5X5X04P",
fp = "QFN-40-1EP_5x5mm_P0.4mm_EP3.6x3.6mm",
},
{
name = "QFN-40_6X6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-40_6X6X05P.kicad_mod",
rotate = "-90",
key = "QFN-40 ,05P ,6X6X05P",
fp = "QFN-40-1EP_6x6mm_P0.5mm_EP4.6x4.6mm",
},
{
name = "QFN-44_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-44_7X7X05P.kicad_mod",
rotate = "-90",
key = "QFN-44 ,05P ,7X7X05P",
fp = "QFN-44-1EP_7x7mm_P0.5mm_EP5.15x5.15mm",
},
{
name = "QFN-48_6X6X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-48_6X6X04P.kicad_mod",
rotate = "-90",
key = "QFN-48 ,04P ,6X6X04P",
fp = "QFN-48-1EP",
},
{
name = "QFN-48_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-48_7X7X05P.kicad_mod",
rotate = "-90",
key = "QFN-48 ,05P ,7X7X05P",
fp = "QFN-48-1EP_7x7mm_P0.5mm_EP5.15x5.15mm",
},
{
name = "QFN-56_8X8X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-56_8X8X05P.kicad_mod",
rotate = "-90",
key = "QFN-56 ,05P ,8X8X05P",
fp = "QFN-56-1EP_7x7mm_P0.4mm_EP5.6x5.6mm",
},
{
name = "QFN-64_9X9X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-64_9X9X05P.kicad_mod",
rotate = "-90",
key = "QFN-64 ,05P ,9X9X05P",
fp = "QFN-64-1EP_9x9mm_P0.5mm_EP7.35x7.35mm",
},
{
name = "QFN-68_8X8X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-68_8X8X04P.kicad_mod",
rotate = "-90",
key = "QFN-68 ,04P ,8X8X04P",
fp = "",
},
{
name = "QFN-6_2X2X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-6_2X2X065P.kicad_mod",
rotate = "-90",
key = "QFN-6 ,065P ,2X2X065P",
fp = "",
},
{
name = "QFN-6_3X3X095P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-6_3X3X095P.kicad_mod",
rotate = "-90",
key = "QFN-6 ,095P ,3X3X095P",
fp = "",
},
{
name = "QFN-76_9X9X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-76_9X9X04P.kicad_mod",
rotate = "-90",
key = "QFN-76 ,04P ,9X9X04P",
fp = "",
},
{
name = "QFN-8_3X3X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-8_3X3X065P.kicad_mod",
rotate = "-90",
key = "QFN-8 ,065P ,3X3X065P",
fp = "",
},
{
name = "QFN-8_5X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFN-8_5X3MM.kicad_mod",
rotate = "-90",
key = "QFN-8 ,5X3MM",
fp = "",
},
{
name = "QFP-100_14X14X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-100_14X14X05P.kicad_mod",
rotate = "-90",
key = "QFP-100 ,05P ,14X14X05P",
fp = "",
},
{
name = "QFP-100_14X20X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-100_14X20X065P.kicad_mod",
rotate = "-90",
key = "QFP-100 ,065P ,14X20X065P",
fp = "",
},
{
name = "QFP-144_20X20X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-144_20X20X05P.kicad_mod",
rotate = "-90",
key = "QFP-144 ,05P ,20X20X05P",
fp = "",
},
{
name = "QFP-208_28X28X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-208_28X28X05P.kicad_mod",
rotate = "-90",
key = "QFP-208 ,05P ,28X28X05P",
fp = "",
},
{
name = "QFP-44_10X10X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-44_10X10X08P.kicad_mod",
rotate = "-90",
key = "QFP-44 ,08P ,10X10X08P",
fp = "",
},
{
name = "QFP-64_10X10X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-64_10X10X05P.kicad_mod",
rotate = "-90",
key = "QFP-64 ,05P ,10X10X05P",
fp = "",
},
{
name = "QFP-64_14X14X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP-64_14X14X08P.kicad_mod",
rotate = "-90",
key = "QFP-64 ,08P ,14X14X08P",
fp = "",
},
{
name = "QFP5-60",
path = "X:/lc_kicad_lib/lc_lib.pretty/QFP5-60.kicad_mod",
rotate = "-90",
key = "5P ,QFP5-60",
fp = "",
},
{
name = "QSOP-16_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/QSOP-16_150MIL.kicad_mod",
rotate = "-90",
key = "QSOP-16 ,150MIL",
fp = "QSOP-16_3.9x4.9mm_P0.635mm",
},
{
name = "QSOP-24_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/QSOP-24_150MIL.kicad_mod",
rotate = "-90",
key = "QSOP-24 ,150MIL",
fp = "QSOP-24_3.9x8.7mm_P0.635mm",
},
{
name = "QVSOP-40",
path = "X:/lc_kicad_lib/lc_lib.pretty/QVSOP-40.kicad_mod",
rotate = "-90",
key = "QVSOP-40",
fp = "",
},
{
name = "R-1",
path = "X:/lc_kicad_lib/lc_lib.pretty/R-1.kicad_mod",
rotate = "180",
key = "R-1",
fp = "",
},
{
name = "R-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/R-6.kicad_mod",
rotate = "180",
key = "R-6",
fp = "D_P600_R-6_P12.70mm_Horizontal",
},
{
name = "RD91",
path = "X:/lc_kicad_lib/lc_lib.pretty/RD91.kicad_mod",
rotate = "90",
key = "RD91",
fp = "",
},
{
name = "S-PBGA-N423",
path = "X:/lc_kicad_lib/lc_lib.pretty/S-PBGA-N423.kicad_mod",
rotate = "-90",
key = "S-PBGA-N423",
fp = "",
},
{
name = "SC-101",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-101.kicad_mod",
rotate = "180",
key = "SC-101",
fp = "",
},
{
name = "SC-61",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-61.kicad_mod",
rotate = "0",
key = "SC-61",
fp = "",
},
{
name = "SC-70(SC-70-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-70(SC-70-3).kicad_mod",
rotate = "180",
key = "SC-70 ,SC-70-3",
fp = "SOT-323_SC-70",
},
{
name = "SC-70-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-70-5.kicad_mod",
rotate = "180",
key = "SC-70-5",
fp = "SOT-353_SC-70-5",
},
{
name = "SC-70-6(SOT-363)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-70-6(SOT-363).kicad_mod",
rotate = "0",
key = "SC-70-6 ,SOT-363",
fp = "SOT-363_SC-70-6",
},
{
name = "SC-74",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-74.kicad_mod",
rotate = "180",
key = "SC-74",
fp = "",
},
{
name = "SC-75(SOT-523)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-75(SOT-523).kicad_mod",
rotate = "180",
key = "SC-75 ,SOT-523",
fp = "",
},
{
name = "SC-88A",
path = "X:/lc_kicad_lib/lc_lib.pretty/SC-88A.kicad_mod",
rotate = "180",
key = "SC-88A",
fp = "",
},
{
name = "SIP8-P-2.54A",
path = "X:/lc_kicad_lib/lc_lib.pretty/SIP8-P-2.54A.kicad_mod",
rotate = "0",
key = "8P ,SIP8-P-2.54A",
fp = "",
},
{
name = "SIP9-P-2.54A",
path = "X:/lc_kicad_lib/lc_lib.pretty/SIP9-P-2.54A.kicad_mod",
rotate = "0",
key = "9P ,SIP9-P-2.54A",
fp = "",
},
{
name = "SLA-23",
path = "X:/lc_kicad_lib/lc_lib.pretty/SLA-23.kicad_mod",
rotate = "-90",
key = "SLA-23",
fp = "",
},
{
name = "SLP2510P8",
path = "X:/lc_kicad_lib/lc_lib.pretty/SLP2510P8.kicad_mod",
rotate = "-90",
key = "8P ,SLP2510P8",
fp = "",
},
{
name = "SM8",
path = "X:/lc_kicad_lib/lc_lib.pretty/SM8.kicad_mod",
rotate = "-90",
key = "SM8",
fp = "",
},
{
name = "SMA(DO-214AC)_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMA(DO-214AC)_S1.kicad_mod",
rotate = "180",
key = "SMA ,DO-214AC ,S1",
fp = "DO-214-AC_SMA",
},
{
name = "SMA(DO-214AC)_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMA(DO-214AC)_S2.kicad_mod",
rotate = "180",
key = "SMA ,DO-214AC ,S2",
fp = "DO-214-AC_SMA",
},
{
name = "SMA(DO-214AC)_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMA(DO-214AC)_S3.kicad_mod",
rotate = "180",
key = "SMA ,DO-214AC ,S3",
fp = "DO-214-AC_SMA",
},
{
name = "SMA(DO-214AC)_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMA(DO-214AC)_S4.kicad_mod",
rotate = "180",
key = "SMA ,DO-214AC ,S4",
fp = "DO-214-AC_SMA",
},
{
name = "SMA(DO-214AC)_S5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMA(DO-214AC)_S5.kicad_mod",
rotate = "180",
key = "SMA ,DO-214AC ,S5",
fp = "DO-214-AC_SMA",
},
{
name = "SMAF_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMAF_S1.kicad_mod",
rotate = "180",
key = "SMAF ,S1",
fp = "",
},
{
name = "SMAF_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMAF_S2.kicad_mod",
rotate = "180",
key = "SMAF ,S2",
fp = "",
},
{
name = "SMAF_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMAF_S3.kicad_mod",
rotate = "180",
key = "SMAF ,S3",
fp = "",
},
{
name = "SMAF_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMAF_S4.kicad_mod",
rotate = "180",
key = "SMAF ,S4",
fp = "",
},
{
name = "SMAF_S5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMAF_S5.kicad_mod",
rotate = "180",
key = "SMAF ,S5",
fp = "",
},
{
name = "SMB(DO-214AA)_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMB(DO-214AA)_S1.kicad_mod",
rotate = "180",
key = "SMB ,DO-214AA ,S1",
fp = "DO-214-AA_SMB",
},
{
name = "SMB(DO-214AA)_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMB(DO-214AA)_S2.kicad_mod",
rotate = "180",
key = "SMB ,DO-214AA ,S2",
fp = "DO-214-AA_SMB",
},
{
name = "SMB(DO-214AA)_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMB(DO-214AA)_S3.kicad_mod",
rotate = "180",
key = "SMB ,DO-214AA ,S3",
fp = "DO-214-AA_SMB",
},
{
name = "SMB(DO-214AA)_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMB(DO-214AA)_S4.kicad_mod",
rotate = "180",
key = "SMB ,DO-214AA ,S4",
fp = "DO-214-AA_SMB",
},
{
name = "SMB(DO-214AA)_S5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMB(DO-214AA)_S5.kicad_mod",
rotate = "180",
key = "SMB ,DO-214AA ,S5",
fp = "DO-214-AA_SMB",
},
{
name = "SMBF_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMBF_S1.kicad_mod",
rotate = "180",
key = "SMBF ,S1",
fp = "",
},
{
name = "SMBF_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMBF_S2.kicad_mod",
rotate = "180",
key = "SMBF ,S2",
fp = "",
},
{
name = "SMBF_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMBF_S3.kicad_mod",
rotate = "180",
key = "SMBF ,S3",
fp = "",
},
{
name = "SMBF_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMBF_S4.kicad_mod",
rotate = "180",
key = "SMBF ,S4",
fp = "",
},
{
name = "SMBF_S5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMBF_S5.kicad_mod",
rotate = "180",
key = "SMBF ,S5",
fp = "",
},
{
name = "SMC(DO-214AB)_S1",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMC(DO-214AB)_S1.kicad_mod",
rotate = "180",
key = "SMC ,DO-214AB ,S1",
fp = "D_SMC",
},
{
name = "SMC(DO-214AB)_S2",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMC(DO-214AB)_S2.kicad_mod",
rotate = "180",
key = "SMC ,DO-214AB ,S2",
fp = "D_SMC",
},
{
name = "SMC(DO-214AB)_S3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMC(DO-214AB)_S3.kicad_mod",
rotate = "180",
key = "SMC ,DO-214AB ,S3",
fp = "D_SMC",
},
{
name = "SMC(DO-214AB)_S4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMC(DO-214AB)_S4.kicad_mod",
rotate = "180",
key = "SMC ,DO-214AB ,S4",
fp = "D_SMC",
},
{
name = "SMC(DO-214AB)_S5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMC(DO-214AB)_S5.kicad_mod",
rotate = "180",
key = "SMC ,DO-214AB ,S5",
fp = "D_SMC",
},
{
name = "SMD-14",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-14.kicad_mod",
rotate = "-90",
key = "SMD ,14 ,SMD-14",
fp = "",
},
{
name = "SMD-3215_2P_FC_-_135",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-3215_2P_FC_-_135.kicad_mod",
rotate = "0",
key = "SMD ,3215 ,SMD-3215 ,2P ,FC ,- ,135",
fp = "",
},
{
name = "SMD-3225_4P",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-3225_4P.kicad_mod",
rotate = "0",
key = "SMD ,3225 ,SMD-3225 ,4P",
fp = "Crystal_SMD_3225-4pin_3.2x2.5mm",
},
{
name = "SMD-4",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-4.kicad_mod",
rotate = "0",
key = "SMD ,4 ,SMD-4",
fp = "",
},
{
name = "SMD-5032_2P",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-5032_2P.kicad_mod",
rotate = "0",
key = "SMD ,5032 ,SMD-5032 ,2P",
fp = "Crystal_SMD_5032-2pin_5.0x3.2mm",
},
{
name = "SMD-5032_4P",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-5032_4P.kicad_mod",
rotate = "0",
key = "SMD ,5032 ,SMD-5032 ,4P",
fp = "Crystal_SMD_5032-2pin_5.0x3.2mm",
},
{
name = "SMD-7050_4P",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-7050_4P.kicad_mod",
rotate = "-90",
key = "SMD ,7050 ,SMD-7050 ,4P",
fp = "",
},
{
name = "SMD-8_6.3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-8_6.3MM.kicad_mod",
rotate = "-90",
key = "SMD ,8 ,SMD-8 ,6.3MM",
fp = "",
},
{
name = "SMD-8_9.0MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD-8_9.0MM.kicad_mod",
rotate = "-90",
key = "SMD ,8 ,SMD-8 ,9.0MM",
fp = "",
},
{
name = "SMD2018",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD2018.kicad_mod",
rotate = "0",
key = "SMD2018",
fp = "",
},
{
name = "SMD2920",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD2920.kicad_mod",
rotate = "0",
key = "SMD2920",
fp = "",
},
{
name = "SMD4532",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD4532.kicad_mod",
rotate = "0",
key = "SMD4532",
fp = "",
},
{
name = "SMD_5X5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMD_5X5MM.kicad_mod",
rotate = "-90",
key = "SMD ,5X5MM",
fp = "",
},
{
name = "SMF_045X",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMF_045X.kicad_mod",
rotate = "180",
key = "SMF ,045X",
fp = "",
},
{
name = "SMT-6_6.3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SMT-6_6.3MM.kicad_mod",
rotate = "-90",
key = "SMT-6 ,6.3MM",
fp = "",
},
{
name = "SO-8_3.9MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SO-8_3.9MM.kicad_mod",
rotate = "-90",
key = "SO-8 ,3.9MM",
fp = "",
},
{
name = "SO-8_4.4MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SO-8_4.4MM.kicad_mod",
rotate = "-90",
key = "SO-8 ,4.4MM",
fp = "",
},
{
name = "SO-8_7.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SO-8_7.5MM.kicad_mod",
rotate = "-90",
key = "SO-8 ,7.5MM",
fp = "",
},
{
name = "SOD-123",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-123.kicad_mod",
rotate = "180",
key = "SOD-123",
fp = "D_SOD-123",
},
{
name = "SOD-123F",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-123F.kicad_mod",
rotate = "180",
key = "SOD-123F",
fp = "D_SOD-123F",
},
{
name = "SOD-323",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-323.kicad_mod",
rotate = "180",
key = "SOD-323",
fp = "D_SOD-323",
},
{
name = "SOD-323F",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-323F.kicad_mod",
rotate = "180",
key = "SOD-323F",
fp = "D_SOD-323F",
},
{
name = "SOD-523",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-523.kicad_mod",
rotate = "180",
key = "SOD-523",
fp = "D_SOD-523",
},
{
name = "SOD-57",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-57.kicad_mod",
rotate = "180",
key = "SOD-57",
fp = "",
},
{
name = "SOD-64",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-64.kicad_mod",
rotate = "180",
key = "SOD-64",
fp = "",
},
{
name = "SOD-723",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-723.kicad_mod",
rotate = "180",
key = "SOD-723",
fp = "",
},
{
name = "SOD-882",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-882.kicad_mod",
rotate = "180",
key = "SOD-882",
fp = "",
},
{
name = "SOD-923",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOD-923.kicad_mod",
rotate = "180",
key = "SOD-923",
fp = "",
},
{
name = "SOIC-10_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-10_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-10 ,150MIL",
fp = "",
},
{
name = "SOIC-14_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-14_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-14 ,150MIL",
fp = "SOIC-14_3.9x8.7mm_P1.27mm",
},
{
name = "SOIC-14_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-14_208MIL.kicad_mod",
rotate = "-90",
key = "SOIC-14 ,208MIL",
fp = "SOIC-14_3.9x8.7mm_P1.27mm",
},
{
name = "SOIC-14_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-14_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-14 ,300MIL",
fp = "SOIC-14_3.9x8.7mm_P1.27mm",
},
{
name = "SOIC-16_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-16_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-16 ,150MIL",
fp = "SOIC-16_3.9x9.9mm_P1.27mm",
},
{
name = "SOIC-16_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-16_208MIL.kicad_mod",
rotate = "-90",
key = "SOIC-16 ,208MIL",
fp = "SOIC-16_3.9x9.9mm_P1.27mm",
},
{
name = "SOIC-16_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-16_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-16 ,300MIL",
fp = "SOIC-16_3.9x9.9mm_P1.27mm",
},
{
name = "SOIC-18_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-18_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-18 ,300MIL",
fp = "",
},
{
name = "SOIC-20_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-20_208MIL.kicad_mod",
rotate = "-90",
key = "SOIC-20 ,208MIL",
fp = "",
},
{
name = "SOIC-20_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-20_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-20 ,300MIL",
fp = "",
},
{
name = "SOIC-24_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-24_208MIL.kicad_mod",
rotate = "-90",
key = "SOIC-24 ,208MIL",
fp = "SOIC-24",
},
{
name = "SOIC-24_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-24_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-24 ,300MIL",
fp = "SOIC-24",
},
{
name = "SOIC-28_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-28_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-28 ,300MIL",
fp = "",
},
{
name = "SOIC-32_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-32_300MIL.kicad_mod",
rotate = "-90",
key = "SOIC-32 ,300MIL",
fp = "",
},
{
name = "SOIC-7_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-7_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-7 ,150MIL",
fp = "",
},
{
name = "SOIC-8_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-8_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-8 ,150MIL",
fp = "SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.35x2.35mm",
},
{
name = "SOIC-8_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-8_208MIL.kicad_mod",
rotate = "-90",
key = "SOIC-8 ,208MIL",
fp = "SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.35x2.35mm",
},
{
name = "SOIC-8_EP_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOIC-8_EP_150MIL.kicad_mod",
rotate = "-90",
key = "SOIC-8 ,EP ,150MIL",
fp = "SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.35x2.35mm",
},
{
name = "SOJ-28_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOJ-28_300MIL.kicad_mod",
rotate = "-90",
key = "SOJ-28 ,300MIL",
fp = "",
},
{
name = "SOJ-32_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOJ-32_300MIL.kicad_mod",
rotate = "-90",
key = "SOJ-32 ,300MIL",
fp = "SOJ-32",
},
{
name = "SOJ-32_400MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOJ-32_400MIL.kicad_mod",
rotate = "-90",
key = "SOJ-32 ,400MIL",
fp = "SOJ-32",
},
{
name = "SOJ-36_400MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOJ-36_400MIL.kicad_mod",
rotate = "-90",
key = "SOJ-36 ,400MIL",
fp = "",
},
{
name = "SOJ-44_400MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOJ-44_400MIL.kicad_mod",
rotate = "-90",
key = "SOJ-44 ,400MIL",
fp = "",
},
{
name = "SON-10_3X3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-10_3X3MM.kicad_mod",
rotate = "-90",
key = "SON-10 ,3X3MM",
fp = "",
},
{
name = "SON-6_1X1.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-6_1X1.5MM.kicad_mod",
rotate = "-90",
key = "SON-6 ,1X1.5MM",
fp = "",
},
{
name = "SON-6_2X2MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-6_2X2MM.kicad_mod",
rotate = "0",
key = "SON-6 ,2X2MM",
fp = "",
},
{
name = "SON-8_3.3X3.3MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-8_3.3X3.3MM.kicad_mod",
rotate = "-90",
key = "SON-8 ,3.3X3.3MM",
fp = "",
},
{
name = "SON-8_3.5X4.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-8_3.5X4.5MM.kicad_mod",
rotate = "-90",
key = "SON-8 ,3.5X4.5MM",
fp = "",
},
{
name = "SON-8_5X6MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/SON-8_5X6MM.kicad_mod",
rotate = "-90",
key = "SON-8 ,5X6MM",
fp = "",
},
{
name = "SOP-14_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-14_150MIL.kicad_mod",
rotate = "-90",
key = "SOP-14 ,150MIL",
fp = "",
},
{
name = "SOP-14_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-14_208MIL.kicad_mod",
rotate = "-90",
key = "SOP-14 ,208MIL",
fp = "",
},
{
name = "SOP-16_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-16_150MIL.kicad_mod",
rotate = "-90",
key = "SOP-16 ,150MIL",
fp = "SOP-16_4.4x10.4mm_P1.27mm",
},
{
name = "SOP-16_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-16_208MIL.kicad_mod",
rotate = "-90",
key = "SOP-16 ,208MIL",
fp = "SOP-16_4.4x10.4mm_P1.27mm",
},
{
name = "SOP-16_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-16_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-16 ,300MIL",
fp = "SOP-16_4.4x10.4mm_P1.27mm",
},
{
name = "SOP-18_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-18_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-18 ,300MIL",
fp = "",
},
{
name = "SOP-20_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-20_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-20 ,300MIL",
fp = "",
},
{
name = "SOP-24_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-24_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-24 ,300MIL",
fp = "",
},
{
name = "SOP-28_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-28_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-28 ,300MIL",
fp = "",
},
{
name = "SOP-32_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-32_300MIL.kicad_mod",
rotate = "-90",
key = "SOP-32 ,300MIL",
fp = "",
},
{
name = "SOP-4_P1.27",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-4_P1.27.kicad_mod",
rotate = "0",
key = "SOP-4 ,127P ,P1.27",
fp = "SOP-4_4.4x2.8mm_P1.27mm",
},
{
name = "SOP-4_P2.54",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-4_P2.54.kicad_mod",
rotate = "0",
key = "SOP-4 ,254P ,P2.54",
fp = "SOP-4_3.8x4.1mm_P2.54mm",
},
{
name = "SOP-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-5.kicad_mod",
rotate = "0",
key = "SOP-5",
fp = "",
},
{
name = "SOP-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-6.kicad_mod",
rotate = "-90",
key = "SOP-6",
fp = "MFSOP6-4_4.4x3.6mm_P1.27mm",
},
{
name = "SOP-7-225-1.27",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-7-225-1.27.kicad_mod",
rotate = "-90",
key = "SOP-7-225-1.27",
fp = "",
},
{
name = "SOP-8_122MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-8_122MIL.kicad_mod",
rotate = "-90",
key = "SOP-8 ,122MIL",
fp = "",
},
{
name = "SOP-8_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-8_150MIL.kicad_mod",
rotate = "-90",
key = "SOP-8 ,150MIL",
fp = "",
},
{
name = "SOP-8_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-8_208MIL.kicad_mod",
rotate = "-90",
key = "SOP-8 ,208MIL",
fp = "",
},
{
name = "SOP-8_268MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-8_268MIL.kicad_mod",
rotate = "-90",
key = "SOP-8 ,268MIL",
fp = "",
},
{
name = "SOP-8_EP_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOP-8_EP_150MIL.kicad_mod",
rotate = "-90",
key = "SOP-8 ,EP ,150MIL",
fp = "",
},
{
name = "SOT-143",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-143.kicad_mod",
rotate = "180",
key = "SOT-143",
fp = "SOT-143",
},
{
name = "SOT-153",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-153.kicad_mod",
rotate = "180",
key = "SOT-153",
fp = "",
},
{
name = "SOT-163",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-163.kicad_mod",
rotate = "180",
key = "SOT-163",
fp = "",
},
{
name = "SOT-223-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-223-5.kicad_mod",
rotate = "180",
key = "SOT-223-5",
fp = "",
},
{
name = "SOT-223-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-223-6.kicad_mod",
rotate = "180",
key = "SOT-223-6",
fp = "",
},
{
name = "SOT-223",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-223.kicad_mod",
rotate = "180",
key = "SOT-223",
fp = "SOT-223",
},
{
name = "SOT-23(SOT-23-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-23(SOT-23-3).kicad_mod",
rotate = "180",
key = "SOT-23 ,SOT-23-3",
fp = "SOT-23",
},
{
name = "SOT-23-3L",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-23-3L.kicad_mod",
rotate = "180",
key = "SOT-23-3L",
fp = "SOT-23",
},
{
name = "SOT-23-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-23-5.kicad_mod",
rotate = "180",
key = "SOT-23-5",
fp = "SOT-23-5",
},
{
name = "SOT-23-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-23-6.kicad_mod",
rotate = "180",
key = "SOT-23-6",
fp = "SOT-23-6",
},
{
name = "SOT-23-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-23-8.kicad_mod",
rotate = "180",
key = "SOT-23-8",
fp = "SOT-23-8",
},
{
name = "SOT-25",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-25.kicad_mod",
rotate = "180",
key = "SOT-25",
fp = "",
},
{
name = "SOT-32",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-32.kicad_mod",
rotate = "0",
key = "SOT-32",
fp = "",
},
{
name = "SOT-323(SC-70)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-323(SC-70).kicad_mod",
rotate = "180",
key = "SOT-323 ,SC-70",
fp = "SOT-323_SC-70",
},
{
name = "SOT-353",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-353.kicad_mod",
rotate = "180",
key = "SOT-353",
fp = "SOT-353_SC-70-5",
},
{
name = "SOT-363",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-363.kicad_mod",
rotate = "180",
key = "SOT-363",
fp = "SOT-363_SC-70-6",
},
{
name = "SOT-523",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-523.kicad_mod",
rotate = "180",
key = "SOT-523",
fp = "",
},
{
name = "SOT-666",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-666.kicad_mod",
rotate = "180",
key = "SOT-666",
fp = "SOT-666",
},
{
name = "SOT-723",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-723.kicad_mod",
rotate = "180",
key = "SOT-723",
fp = "",
},
{
name = "SOT-753",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-753.kicad_mod",
rotate = "180",
key = "SOT-753",
fp = "",
},
{
name = "SOT-883",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-883.kicad_mod",
rotate = "180",
key = "SOT-883",
fp = "",
},
{
name = "SOT-89(SOT-89-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-89(SOT-89-3).kicad_mod",
rotate = "180",
key = "SOT-89 ,SOT-89-3",
fp = "",
},
{
name = "SOT-89-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-89-5.kicad_mod",
rotate = "180",
key = "SOT-89-5",
fp = "",
},
{
name = "SOT-93",
path = "X:/lc_kicad_lib/lc_lib.pretty/SOT-93.kicad_mod",
rotate = "0",
key = "SOT-93",
fp = "TO-218_SOT93_Vertical",
},
{
name = "SPMCA-027",
path = "X:/lc_kicad_lib/lc_lib.pretty/SPMCA-027.kicad_mod",
rotate = "-90",
key = "SPMCA-027",
fp = "",
},
{
name = "SSOP-10_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-10_150MIL.kicad_mod",
rotate = "-90",
key = "SSOP-10 ,150MIL",
fp = "",
},
{
name = "SSOP-14_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-14_208MIL.kicad_mod",
rotate = "-90",
key = "SSOP-14 ,208MIL",
fp = "SSOP-14",
},
{
name = "SSOP-16_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-16_150MIL.kicad_mod",
rotate = "-90",
key = "SSOP-16 ,150MIL",
fp = "SSOP-16_3.9x4.9mm_P0.635mm",
},
{
name = "SSOP-16_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-16_208MIL.kicad_mod",
rotate = "-90",
key = "SSOP-16 ,208MIL",
fp = "SSOP-16_3.9x4.9mm_P0.635mm",
},
{
name = "SSOP-20_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-20_150MIL.kicad_mod",
rotate = "-90",
key = "SSOP-20 ,150MIL",
fp = "SSOP-20",
},
{
name = "SSOP-20_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-20_208MIL.kicad_mod",
rotate = "-90",
key = "SSOP-20 ,208MIL",
fp = "SSOP-20",
},
{
name = "SSOP-24_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-24_208MIL.kicad_mod",
rotate = "-90",
key = "SSOP-24 ,208MIL",
fp = "SSOP-24_3.9x8.7mm_P0.635mm",
},
{
name = "SSOP-28_150MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-28_150MIL.kicad_mod",
rotate = "-90",
key = "SSOP-28 ,150MIL",
fp = "SSOP-28",
},
{
name = "SSOP-28_208MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-28_208MIL.kicad_mod",
rotate = "-90",
key = "SSOP-28 ,208MIL",
fp = "SSOP-28",
},
{
name = "SSOP-36_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-36_300MIL.kicad_mod",
rotate = "-90",
key = "SSOP-36 ,300MIL",
fp = "",
},
{
name = "SSOP-44K",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-44K.kicad_mod",
rotate = "-90",
key = "SSOP-44K",
fp = "",
},
{
name = "SSOP-48_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-48_300MIL.kicad_mod",
rotate = "-90",
key = "SSOP-48 ,300MIL",
fp = "SSOP-48_7.5x15.9mm_P0.635mm",
},
{
name = "SSOP-56_300MIL",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-56_300MIL.kicad_mod",
rotate = "-90",
key = "SSOP-56 ,300MIL",
fp = "SSOP-56_7.5x18.5mm_P0.635mm",
},
{
name = "SSOP-B40",
path = "X:/lc_kicad_lib/lc_lib.pretty/SSOP-B40.kicad_mod",
rotate = "-90",
key = "SSOP-B40",
fp = "",
},
{
name = "STSOP-32",
path = "X:/lc_kicad_lib/lc_lib.pretty/STSOP-32.kicad_mod",
rotate = "0",
key = "STSOP-32",
fp = "",
},
{
name = "SUPERSOT-3",
path = "X:/lc_kicad_lib/lc_lib.pretty/SUPERSOT-3.kicad_mod",
rotate = "180",
key = "SUPERSOT-3",
fp = "SuperSOT-3",
},
{
name = "SUPERSOT-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/SUPERSOT-6.kicad_mod",
rotate = "180",
key = "SUPERSOT-6",
fp = "SuperSOT-6",
},
{
name = "TBS",
path = "X:/lc_kicad_lib/lc_lib.pretty/TBS.kicad_mod",
rotate = "180",
key = "TBS",
fp = "",
},
{
name = "TDFN-14_EP",
path = "X:/lc_kicad_lib/lc_lib.pretty/TDFN-14_EP.kicad_mod",
rotate = "-90",
key = "TDFN-14 ,EP",
fp = "",
},
{
name = "TFBGA-180",
path = "X:/lc_kicad_lib/lc_lib.pretty/TFBGA-180.kicad_mod",
rotate = "-90",
key = "TFBGA-180",
fp = "",
},
{
name = "TFBGA-64",
path = "X:/lc_kicad_lib/lc_lib.pretty/TFBGA-64.kicad_mod",
rotate = "-90",
key = "TFBGA-64",
fp = "",
},
{
name = "TO-126-4",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-126-4.kicad_mod",
rotate = "0",
key = "TO-126-4",
fp = "",
},
{
name = "TO-126",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-126.kicad_mod",
rotate = "0",
key = "TO-126",
fp = "TO-126_Horizontal",
},
{
name = "TO-202",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-202.kicad_mod",
rotate = "0",
key = "TO-202",
fp = "",
},
{
name = "TO-218",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-218.kicad_mod",
rotate = "0",
key = "TO-218",
fp = "TO-218_SOT93_Vertical",
},
{
name = "TO-220(TO-220-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220(TO-220-3).kicad_mod",
rotate = "0",
key = "TO-220 ,TO-220-3",
fp = "TO-220_Horizontal",
},
{
name = "TO-220-5(FORMING)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220-5(FORMING).kicad_mod",
rotate = "0",
key = "TO-220-5 ,FORMING",
fp = "TO-220-5_P3.4x3.7mm_StaggerEven_Lead3.8mm_Vertical",
},
{
name = "TO-220-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220-5.kicad_mod",
rotate = "0",
key = "TO-220-5",
fp = "TO-220-5_P3.4x3.7mm_StaggerEven_Lead3.8mm_Vertical",
},
{
name = "TO-220-7C",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220-7C.kicad_mod",
rotate = "-90",
key = "TO-220-7C",
fp = "",
},
{
name = "TO-220AC(TO-220-2)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220AC(TO-220-2).kicad_mod",
rotate = "0",
key = "TO-220AC ,TO-220-2",
fp = "",
},
{
name = "TO-220F(TO-220IS)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220F(TO-220IS).kicad_mod",
rotate = "0",
key = "TO-220F ,TO-220IS",
fp = "",
},
{
name = "TO-220F-4L(FORMING)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-220F-4L(FORMING).kicad_mod",
rotate = "0",
key = "TO-220F-4L ,FORMING",
fp = "",
},
{
name = "TO-225",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-225.kicad_mod",
rotate = "0",
key = "TO-225",
fp = "",
},
{
name = "TO-247(AC)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-247(AC).kicad_mod",
rotate = "0",
key = "TO-247 ,AC",
fp = "TO-247_TO-3P_Vertical",
},
{
name = "TO-251(I-PAK)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-251(I-PAK).kicad_mod",
rotate = "0",
key = "TO-251 ,I-PAK",
fp = "",
},
{
name = "TO-252-2-180",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-252-2-180.kicad_mod",
rotate = "0",
key = "TO-252-2-180",
fp = "",
},
{
name = "TO-252-2",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-252-2.kicad_mod",
rotate = "180",
key = "TO-252-2",
fp = "TO-252-2",
},
{
name = "TO-252-3",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-252-3.kicad_mod",
rotate = "180",
key = "TO-252-3",
fp = "TO-252-3_TabPin2",
},
{
name = "TO-252-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-252-5.kicad_mod",
rotate = "180",
key = "TO-252-5",
fp = "TO-252-5_TabPin3",
},
{
name = "TO-263-2",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-263-2.kicad_mod",
rotate = "180",
key = "TO-263-2",
fp = "TO-263-2",
},
{
name = "TO-263-3",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-263-3.kicad_mod",
rotate = "180",
key = "TO-263-3",
fp = "TO-263-3_TabPin2",
},
{
name = "TO-263-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-263-5.kicad_mod",
rotate = "180",
key = "TO-263-5",
fp = "TO-263-5_TabPin3",
},
{
name = "TO-263-7",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-263-7.kicad_mod",
rotate = "180",
key = "TO-263-7",
fp = "TO-263-7_TabPin4",
},
{
name = "TO-264",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-264.kicad_mod",
rotate = "0",
key = "TO-264",
fp = "",
},
{
name = "TO-274AA(SUPER-247)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-274AA(SUPER-247).kicad_mod",
rotate = "0",
key = "TO-274AA ,SUPER-247",
fp = "",
},
{
name = "TO-277A(SMPC)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-277A(SMPC).kicad_mod",
rotate = "180",
key = "TO-277A ,SMPC",
fp = "TO-277A",
},
{
name = "TO-3",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-3.kicad_mod",
rotate = "-90",
key = "TO-3",
fp = "TO-3",
},
{
name = "TO-39",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-39.kicad_mod",
rotate = "0",
key = "TO-39",
fp = "",
},
{
name = "TO-3P-5L",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-3P-5L.kicad_mod",
rotate = "0",
key = "3P ,TO-3P-5L",
fp = "",
},
{
name = "TO-3P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-3P.kicad_mod",
rotate = "0",
key = "3P ,TO-3P",
fp = "TO-247_TO-3P_Vertical",
},
{
name = "TO-52",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-52.kicad_mod",
rotate = "180",
key = "TO-52",
fp = "",
},
{
name = "TO-92(TO-92-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92(TO-92-3).kicad_mod",
rotate = "0",
key = "TO-92 ,TO-92-3",
fp = "TO-92",
},
{
name = "TO-92-2",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92-2.kicad_mod",
rotate = "0",
key = "TO-92-2",
fp = "Heraeus_TO-92-2",
},
{
name = "TO-92-3L",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92-3L.kicad_mod",
rotate = "0",
key = "TO-92-3L",
fp = "",
},
{
name = "TO-92L",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92L.kicad_mod",
rotate = "0",
key = "TO-92L",
fp = "TO-92L",
},
{
name = "TO-92MOD",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92MOD.kicad_mod",
rotate = "0",
key = "TO-92MOD",
fp = "",
},
{
name = "TO-92_FORMING1",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92_FORMING1.kicad_mod",
rotate = "0",
key = "TO-92 ,FORMING1",
fp = "TO-92",
},
{
name = "TO-92_FORMING2",
path = "X:/lc_kicad_lib/lc_lib.pretty/TO-92_FORMING2.kicad_mod",
rotate = "0",
key = "TO-92 ,FORMING2",
fp = "TO-92",
},
{
name = "TOP3",
path = "X:/lc_kicad_lib/lc_lib.pretty/TOP3.kicad_mod",
rotate = "0",
key = "3P ,TOP3",
fp = "",
},
{
name = "TQFN-16_2.5X2.5X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFN-16_2.5X2.5X04P.kicad_mod",
rotate = "-90",
key = "TQFN-16 ,04P ,2.5X2.5X04P",
fp = "",
},
{
name = "TQFN-16_4X4X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFN-16_4X4X065P.kicad_mod",
rotate = "-90",
key = "TQFN-16 ,065P ,4X4X065P",
fp = "",
},
{
name = "TQFN-20_2.5X4.5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFN-20_2.5X4.5X05P.kicad_mod",
rotate = "-90",
key = "TQFN-20 ,05P ,2.5X4.5X05P",
fp = "",
},
{
name = "TQFN-24_EP_4X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFN-24_EP_4X5X05P.kicad_mod",
rotate = "-90",
key = "TQFN-24 ,EP ,05P ,4X5X05P",
fp = "",
},
{
name = "TQFP-100_12X12X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-100_12X12X04P.kicad_mod",
rotate = "-90",
key = "TQFP-100 ,04P ,12X12X04P",
fp = "TQFP-100_12x12mm_P0.4mm",
},
{
name = "TQFP-100_14X14X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-100_14X14X05P.kicad_mod",
rotate = "-90",
key = "TQFP-100 ,05P ,14X14X05P",
fp = "TQFP-100-1EP_14x14mm_P0.5mm_EP5x5mm",
},
{
name = "TQFP-100_14X20X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-100_14X20X065P.kicad_mod",
rotate = "-90",
key = "TQFP-100 ,065P ,14X20X065P",
fp = "TQFP-100",
},
{
name = "TQFP-128_14X14X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-128_14X14X04P.kicad_mod",
rotate = "-90",
key = "TQFP-128 ,04P ,14X14X04P",
fp = "TQFP-128_14x14mm_P0.4mm",
},
{
name = "TQFP-128_20X14X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-128_20X14X05P.kicad_mod",
rotate = "-90",
key = "TQFP-128 ,05P ,20X14X05P",
fp = "TQFP-128_14x14mm_P0.4mm",
},
{
name = "TQFP-144_20X20X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-144_20X20X05P.kicad_mod",
rotate = "-90",
key = "TQFP-144 ,05P ,20X20X05P",
fp = "TQFP-144_20x20mm_P0.5mm",
},
{
name = "TQFP-32_5X5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-32_5X5X05P.kicad_mod",
rotate = "-90",
key = "TQFP-32 ,05P ,5X5X05P",
fp = "TQFP-32",
},
{
name = "TQFP-32_7X7X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-32_7X7X08P.kicad_mod",
rotate = "-90",
key = "TQFP-32 ,08P ,7X7X08P",
fp = "TQFP-32_7x7mm_P0.8mm",
},
{
name = "TQFP-44_10X10X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-44_10X10X08P.kicad_mod",
rotate = "-90",
key = "TQFP-44 ,08P ,10X10X08P",
fp = "TQFP-44-1EP_10x10mm_P0.8mm_EP4.5x4.5mm",
},
{
name = "TQFP-48_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-48_7X7X05P.kicad_mod",
rotate = "-90",
key = "TQFP-48 ,05P ,7X7X05P",
fp = "TQFP-48-1EP_7x7mm_P0.5mm_EP3.5x3.5mm",
},
{
name = "TQFP-52_10X10X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-52_10X10X065P.kicad_mod",
rotate = "-90",
key = "TQFP-52 ,065P ,10X10X065P",
fp = "",
},
{
name = "TQFP-64_10X10X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-64_10X10X05P.kicad_mod",
rotate = "-90",
key = "TQFP-64 ,05P ,10X10X05P",
fp = "TQFP-64-1EP_10x10mm_P0.5mm_EP8x8mm",
},
{
name = "TQFP-64_14X14X08P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-64_14X14X08P.kicad_mod",
rotate = "-90",
key = "TQFP-64 ,08P ,14X14X08P",
fp = "TQFP-64_14x14mm_P0.8mm",
},
{
name = "TQFP-80_12X12X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TQFP-80_12X12X05P.kicad_mod",
rotate = "-90",
key = "TQFP-80 ,05P ,12X12X05P",
fp = "TQFP-80_12x12mm_P0.5mm",
},
{
name = "TSOC-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOC-6.kicad_mod",
rotate = "180",
key = "TSOC-6",
fp = "",
},
{
name = "TSOP(II)-44",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP(II)-44.kicad_mod",
rotate = "-90",
key = "TSOP ,II ,-44",
fp = "",
},
{
name = "TSOP(II)-54",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP(II)-54.kicad_mod",
rotate = "-90",
key = "TSOP ,II ,-54",
fp = "",
},
{
name = "TSOP(II)-66",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP(II)-66.kicad_mod",
rotate = "-90",
key = "TSOP ,II ,-66",
fp = "",
},
{
name = "TSOP-28",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-28.kicad_mod",
rotate = "0",
key = "TSOP-28",
fp = "",
},
{
name = "TSOP-32",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-32.kicad_mod",
rotate = "0",
key = "TSOP-32",
fp = "",
},
{
name = "TSOP-48",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-48.kicad_mod",
rotate = "0",
key = "TSOP-48",
fp = "",
},
{
name = "TSOP-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-5.kicad_mod",
rotate = "180",
key = "TSOP-5",
fp = "",
},
{
name = "TSOP-56_14X20MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-56_14X20MM.kicad_mod",
rotate = "0",
key = "TSOP-56 ,14X20MM",
fp = "",
},
{
name = "TSOP-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOP-6.kicad_mod",
rotate = "180",
key = "TSOP-6",
fp = "",
},
{
name = "TSOT-23-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOT-23-5.kicad_mod",
rotate = "180",
key = "TSOT-23-5",
fp = "TSOT-23-5",
},
{
name = "TSOT-23-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOT-23-6.kicad_mod",
rotate = "180",
key = "TSOT-23-6",
fp = "TSOT-23-6_MK06A",
},
{
name = "TSOT-23-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSOT-23-8.kicad_mod",
rotate = "-90",
key = "TSOT-23-8",
fp = "TSOT-23-8",
},
{
name = "TSSOP-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-10.kicad_mod",
rotate = "-90",
key = "TSSOP-10",
fp = "TSSOP-10_3x3mm_P0.5mm",
},
{
name = "TSSOP-14",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-14.kicad_mod",
rotate = "-90",
key = "TSSOP-14",
fp = "TSSOP-14_4.4x5mm_P0.65mm",
},
{
name = "TSSOP-16",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-16.kicad_mod",
rotate = "-90",
key = "TSSOP-16",
fp = "TSSOP-16-1EP_4.4x5mm_P0.65mm",
},
{
name = "TSSOP-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-20.kicad_mod",
rotate = "-90",
key = "TSSOP-20",
fp = "TSSOP-20_4.4x6.5mm_P0.65mm",
},
{
name = "TSSOP-24",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-24.kicad_mod",
rotate = "-90",
key = "TSSOP-24",
fp = "TSSOP-24_4.4x7.8mm_P0.65mm",
},
{
name = "TSSOP-28",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-28.kicad_mod",
rotate = "-90",
key = "TSSOP-28",
fp = "TSSOP-28_4.4x9.7mm_P0.65mm",
},
{
name = "TSSOP-30",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-30.kicad_mod",
rotate = "-90",
key = "TSSOP-30",
fp = "",
},
{
name = "TSSOP-38",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-38.kicad_mod",
rotate = "-90",
key = "TSSOP-38",
fp = "TSSOP-38_4.4x9.7mm_P0.5mm",
},
{
name = "TSSOP-48",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-48.kicad_mod",
rotate = "-90",
key = "TSSOP-48",
fp = "TSSOP-48_6.1x12.5mm_P0.5mm",
},
{
name = "TSSOP-56",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-56.kicad_mod",
rotate = "-90",
key = "TSSOP-56",
fp = "TSSOP-56_6.1x14mm_P0.5mm",
},
{
name = "TSSOP-8_2.3X2X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-8_2.3X2X05P.kicad_mod",
rotate = "-90",
key = "TSSOP-8 ,05P ,2.3X2X05P",
fp = "TSSOP-8_3x3mm_P0.65mm",
},
{
name = "TSSOP-8_3X3X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-8_3X3X065P.kicad_mod",
rotate = "-90",
key = "TSSOP-8 ,065P ,3X3X065P",
fp = "TSSOP-8_3x3mm_P0.65mm",
},
{
name = "TSSOP-8_3X4.4X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/TSSOP-8_3X4.4X065P.kicad_mod",
rotate = "-90",
key = "TSSOP-8 ,065P ,3X4.4X065P",
fp = "TSSOP-8_3x3mm_P0.65mm",
},
{
name = "TVSOP-48",
path = "X:/lc_kicad_lib/lc_lib.pretty/TVSOP-48.kicad_mod",
rotate = "-90",
key = "TVSOP-48",
fp = "",
},
{
name = "UDFN-6",
path = "X:/lc_kicad_lib/lc_lib.pretty/UDFN-6.kicad_mod",
rotate = "-90",
key = "UDFN-6",
fp = "",
},
{
name = "UFQFPN-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/UFQFPN-20.kicad_mod",
rotate = "-90",
key = "UFQFPN-20",
fp = "",
},
{
name = "UFQFPN-48",
path = "X:/lc_kicad_lib/lc_lib.pretty/UFQFPN-48.kicad_mod",
rotate = "-90",
key = "UFQFPN-48",
fp = "",
},
{
name = "UMAX-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/UMAX-8.kicad_mod",
rotate = "-90",
key = "UMAX-8",
fp = "",
},
{
name = "UMLP-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/UMLP-10.kicad_mod",
rotate = "-90",
key = "UMLP-10",
fp = "",
},
{
name = "US8",
path = "X:/lc_kicad_lib/lc_lib.pretty/US8.kicad_mod",
rotate = "-90",
key = "US8",
fp = "",
},
{
name = "USC(SOD-323)",
path = "X:/lc_kicad_lib/lc_lib.pretty/USC(SOD-323).kicad_mod",
rotate = "180",
key = "USC ,SOD-323",
fp = "",
},
{
name = "USM(SC-70-3)",
path = "X:/lc_kicad_lib/lc_lib.pretty/USM(SC-70-3).kicad_mod",
rotate = "180",
key = "USM ,SC-70-3",
fp = "",
},
{
name = "USV(SC-70-5)",
path = "X:/lc_kicad_lib/lc_lib.pretty/USV(SC-70-5).kicad_mod",
rotate = "180",
key = "USV ,SC-70-5",
fp = "",
},
{
name = "VDFPN-8(MLP-8)",
path = "X:/lc_kicad_lib/lc_lib.pretty/VDFPN-8(MLP-8).kicad_mod",
rotate = "-90",
key = "VDFPN-8 ,MLP-8",
fp = "",
},
{
name = "VFBGA-20",
path = "X:/lc_kicad_lib/lc_lib.pretty/VFBGA-20.kicad_mod",
rotate = "-90",
key = "VFBGA-20",
fp = "",
},
{
name = "VFBGA-48",
path = "X:/lc_kicad_lib/lc_lib.pretty/VFBGA-48.kicad_mod",
rotate = "-90",
key = "VFBGA-48",
fp = "",
},
{
name = "VFBGA-54_8X14MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/VFBGA-54_8X14MM.kicad_mod",
rotate = "-90",
key = "VFBGA-54 ,8X14MM",
fp = "",
},
{
name = "VFBGA-63",
path = "X:/lc_kicad_lib/lc_lib.pretty/VFBGA-63.kicad_mod",
rotate = "-90",
key = "VFBGA-63",
fp = "",
},
{
name = "VFQFPN-36_6X6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VFQFPN-36_6X6X05P.kicad_mod",
rotate = "-90",
key = "VFQFPN-36 ,05P ,6X6X05P",
fp = "",
},
{
name = "VMN2",
path = "X:/lc_kicad_lib/lc_lib.pretty/VMN2.kicad_mod",
rotate = "180",
key = "VMN2",
fp = "",
},
{
name = "VQFN-14_3.6X3.6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-14_3.6X3.6X05P.kicad_mod",
rotate = "-90",
key = "QFN-14 ,VQFN-14 ,05P ,3.6X3.6X05P",
fp = "",
},
{
name = "VQFN-16_3.6X3.6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-16_3.6X3.6X05P.kicad_mod",
rotate = "-90",
key = "QFN-16 ,VQFN-16 ,05P ,3.6X3.6X05P",
fp = "QFN-16-1EP_3x3mm_P0.5mm_EP1.8x1.8mm",
},
{
name = "VQFN-20_5X5X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-20_5X5X065P.kicad_mod",
rotate = "-90",
key = "QFN-20 ,VQFN-20 ,065P ,5X5X065P",
fp = "QFN-20-1EP_3x4mm_P0.5mm_EP1.65x2.65mm",
},
{
name = "VQFN-24_3.5X5.5X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-24_3.5X5.5X05P.kicad_mod",
rotate = "-90",
key = "QFN-24 ,VQFN-24 ,05P ,3.5X5.5X05P",
fp = "QFN-24-1EP_3x3mm_P0.4mm_EP1.75x1.6mm",
},
{
name = "VQFN-32_4X4X04P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-32_4X4X04P.kicad_mod",
rotate = "-90",
key = "QFN-32 ,VQFN-32 ,04P ,4X4X04P",
fp = "QFN-32-1EP_4x4mm_P0.4mm_EP2.65x2.65mm",
},
{
name = "VQFN-40_6X6X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-40_6X6X05P.kicad_mod",
rotate = "-90",
key = "QFN-40 ,VQFN-40 ,05P ,6X6X05P",
fp = "QFN-40-1EP_5x5mm_P0.4mm_EP3.6x3.6mm",
},
{
name = "VQFN-48_7X7X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VQFN-48_7X7X05P.kicad_mod",
rotate = "-90",
key = "QFN-48 ,VQFN-48 ,05P ,7X7X05P",
fp = "QFN-48-1EP",
},
{
name = "VSO-56",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSO-56.kicad_mod",
rotate = "-90",
key = "VSO-56",
fp = "VSO-56_11.1x21.5mm_P0.75mm",
},
{
name = "VSON-14_3X4X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSON-14_3X4X05P.kicad_mod",
rotate = "-90",
key = "VSON-14 ,05P ,3X4X05P",
fp = "",
},
{
name = "VSON-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSON-8.kicad_mod",
rotate = "-90",
key = "VSON-8",
fp = "VSON-8_3.3x3.3mm_P0.65mm_NexFET",
},
{
name = "VSSOP-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSSOP-10.kicad_mod",
rotate = "-90",
key = "VSSOP-10",
fp = "",
},
{
name = "VSSOP-8_2X2.3X05P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSSOP-8_2X2.3X05P.kicad_mod",
rotate = "-90",
key = "VSSOP-8 ,05P ,2X2.3X05P",
fp = "VSSOP-8_2.3x2mm_P0.5mm",
},
{
name = "VSSOP-8_3X3X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSSOP-8_3X3X065P.kicad_mod",
rotate = "-90",
key = "VSSOP-8 ,065P ,3X3X065P",
fp = "VSSOP-8_3.0x3.0mm_P0.65mm",
},
{
name = "VSSOP-8_EP_3X3X065P",
path = "X:/lc_kicad_lib/lc_lib.pretty/VSSOP-8_EP_3X3X065P.kicad_mod",
rotate = "-90",
key = "VSSOP-8 ,EP ,065P ,3X3X065P",
fp = "VSSOP-8_2.3x2mm_P0.5mm",
},
{
name = "WBGA-84_8X12.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/WBGA-84_8X12.5MM.kicad_mod",
rotate = "-90",
key = "WBGA-84 ,8X12.5MM",
fp = "",
},
{
name = "WBGA-96",
path = "X:/lc_kicad_lib/lc_lib.pretty/WBGA-96.kicad_mod",
rotate = "-90",
key = "WBGA-96",
fp = "",
},
{
name = "WCSP-5",
path = "X:/lc_kicad_lib/lc_lib.pretty/WCSP-5.kicad_mod",
rotate = "-90",
key = "WCSP-5",
fp = "",
},
{
name = "WDFN-10L",
path = "X:/lc_kicad_lib/lc_lib.pretty/WDFN-10L.kicad_mod",
rotate = "-90",
key = "WDFN-10L",
fp = "",
},
{
name = "WLCSP-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/WLCSP-8.kicad_mod",
rotate = "-90",
key = "WLCSP-8",
fp = "",
},
{
name = "WOB",
path = "X:/lc_kicad_lib/lc_lib.pretty/WOB.kicad_mod",
rotate = "0",
key = "WOB",
fp = "",
},
{
name = "WPAK-8",
path = "X:/lc_kicad_lib/lc_lib.pretty/WPAK-8.kicad_mod",
rotate = "-90",
key = "WPAK-8",
fp = "SWPA8040",
},
{
name = "WQFN-10",
path = "X:/lc_kicad_lib/lc_lib.pretty/WQFN-10.kicad_mod",
rotate = "-90",
key = "WQFN-10",
fp = "",
},
{
name = "WSON-10_2.5X2.5MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/WSON-10_2.5X2.5MM.kicad_mod",
rotate = "-90",
key = "WSON-10 ,2.5X2.5MM",
fp = "",
},
{
name = "WSON-8_2X2MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/WSON-8_2X2MM.kicad_mod",
rotate = "-90",
key = "WSON-8 ,2X2MM",
fp = "WSON-8-1EP_3x3mm_P0.5mm_EP1.6x2.0mm",
},
{
name = "WSON-8_5X6MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/WSON-8_5X6MM.kicad_mod",
rotate = "-90",
key = "WSON-8 ,5X6MM",
fp = "WSON-8-1EP_3x3mm_P0.5mm_EP1.6x2.0mm",
},
{
name = "XSON-6_1X1.45MM",
path = "X:/lc_kicad_lib/lc_lib.pretty/XSON-6_1X1.45MM.kicad_mod",
rotate = "-90",
key = "XSON-6 ,1X1.45MM",
fp = "",
},
{
name = "ZIP-23",
path = "X:/lc_kicad_lib/lc_lib.pretty/ZIP-23.kicad_mod",
rotate = "-90",
key = "ZIP-23",
fp = "",
},
{
name = "ZIP19-1",
path = "X:/lc_kicad_lib/lc_lib.pretty/ZIP19-1.kicad_mod",
rotate = "0",
key = "19P ,ZIP19-1",
fp = "",
},
}
return fpTable
|
local opts = {noremap = true, silent = true}
local map = vim.api.nvim_set_keymap
map("n", "<leader>pr", ":term pio -f -c vim run<CR>i", opts)
map("n", "<leader>pu", ":term pio -f -c vim run --target upload<CR>i", opts)
map("n", "<leader>pc", ":term pio -f -c vim run --target clean<CR>i", opts)
map("n", "<leader>pp", ":term pio -f -c vim run --target program<CR>i", opts)
map("n", "<leader>pf", ":term pio -f -c vim run --target uploadfs<CR>i", opts)
map("n", "<leader>pi", ":term pio -f -c vim update<CR>i", opts)
map("n", "<leader>pt", ":term pio -f -c vim test<CR>i", opts)
|
-- Note: export_helpers/export_triggers/export_ancillaries*.lua scripts run after all other scripts are run, including all the mod/*.lua scripts, after the LoadingGame,
-- and during the UICreated (game created) events (see cm:load_exported_files calls in wh_campaign_setup.lua).
-- In particular, all the mod/*.lua scripts are guaranteed to be loaded so you don't need to require them.
out("UnitCountBasedUpkeep: setup...")
cm:load_global_script "lib.vanish_safe_caller"
local utils = cm:load_global_script "lib.lbm_utils"
local custom_ui_listeners = cm:load_global_script "lib.lbm_custom_ui_listeners"
local local_faction_name = cm:get_local_faction(true)
if not (local_faction_name and utils.get_faction(local_faction_name)) then
out("UnitCountBasedUpkeep: Autorun running, not applying upkeep penalties for additional units")
return
end
local config = cm:load_global_script "lbm_unit_count_upkeep_config"
-- Function defined in wh_campaign_setup.lua
local is_valid_faction = upkeep_penalty_condition
-- Logic copied from wh_campaign_setup.lua
local function is_valid_army(mf)
return not mf:is_armed_citizenry() and mf:has_general() and not mf:general_character():character_subtype("wh2_main_def_black_ark") -- neither garrison nor black ark
end
local factions_tracker = cm:load_global_script("lbm_factions_tracker").new(is_valid_army)
local orig_upkeep_pct_per_army_calc = cm:load_global_script("lbm_orig_upkeep_pct_per_army_calc").new(factions_tracker)
--local upkeep_calc = cm:load_global_script("lbm_unit_count_upkeep_calc").new(factions_tracker, orig_upkeep_pct_per_army_calc)
-- Computes the unit-count-based faction-wide upkeep % based.
-- If include_details is false or omitted, then returns only the computed upkeep %.
-- Else if include_details is true, then returns a table with entries:
-- * upkeep_pct = the rounded and bounded faction-wide upkeep % (where bounds is simply an upper bound of max_upkeep_ct)
-- * raw_upkeep_pct = the unrounded and unbounded faction-wide upkeep % (aka raw upkeep %)
-- * upkeep_pct_per_unit = the upkeep % per unit
-- * orig_upkeep_pct_per_army = the original upkeep % per army
-- * num_units = the # units, including free (discounted) units
-- * num_unfree_units = the # units, excluding free (discounted) units
-- * is_dummy_upkeep_pct = true if the original upkeep % per army is a dummy 0 (due to <= 1 armies and <= 20 units)
local function get_upkeep_pct(faction, include_details)
local num_units = factions_tracker:get_unit_count(faction)
local num_unfree_units = math.max(0, num_units - config.num_free_units)
local orig_upkeep_pct_per_army, is_dummy_upkeep_pct = orig_upkeep_pct_per_army_calc:get(faction)
local upkeep_pct_per_unit = orig_upkeep_pct_per_army / config.max_num_units_per_army
local raw_upkeep_pct = num_unfree_units * upkeep_pct_per_unit
local upkeep_pct = math.min(config.max_upkeep_pct, math.round(raw_upkeep_pct))
if include_details then
return {
upkeep_pct = upkeep_pct,
raw_upkeep_pct = raw_upkeep_pct,
upkeep_pct_per_unit = upkeep_pct_per_unit,
orig_upkeep_pct_per_army = orig_upkeep_pct_per_army,
num_units = num_units,
num_unfree_units = num_unfree_units,
is_dummy_upkeep_pct = is_dummy_upkeep_pct,
}
else
return upkeep_pct
end
end
local function get_upkeep_pct_details(faction)
return get_upkeep_pct(faction, true)
end
local dummy_upkeep_effect_bundle = config.dummy_upkeep_effect_bundle
local function is_dummy_upkeep_effect_bundle(effect_bundle_name)
return effect_bundle_name == dummy_upkeep_effect_bundle
end
-- XXX: For some reason, the effect bundle icons aren't the same size & position as the original supply lines effect bundle icon, so 'fix' them so that they are the same.
-- The problem is that the variable_upkeep.png has dimensions of 27 x 29 pixels, while the effect bundle icons should each have dimensions of 24 x 24 pixels.
-- The layout special-cases the fake supply lines effect bundle (fake because the actual effect bundles are applied at army-level rather than faction-level and are hidden anyway),
-- so that the extra right 3px width and extra top 5px height appears fine for the supply lines effect icon, but it doesn't work for normal effect bundles,
-- such that an effect bundle with variable_upkeep.png icon will instead be resized down to 24px x 24px.
-- Also for some reason, the (dis)appearance of certain UI components (such as closing certain panels or new faction-wide effect bundle) can cause the fix to at least partially revert,
-- with the way the layout regenerates the top bar that the effect bundle icons appear on.
-- The workaround is two fold:
-- 1) Add a child UIC on the upkeep effect bundle that has its position and image set as if it was the actual original supply lines effect bundle icon.
-- This icon UIC survives certain layout regenerations, such as closing certain panels, while retaining the relative position and visibility of its parent.
-- 2) Have the upkeep effect bundle dummy use a truncated variable_upkeep.png where the right 3px and the top 5px is cropped off to fit into 24px x 24px dimensions.
-- This serves as a fallback if the above icon UIC is ever removed in some other types of layout regenerations, such as when a faction-wide effect bundle is added or removed.
-- Called whenever the upkeep effect bundle dummy is added (see show_dummy_upkeep_effect_bundle) and whenever an effect bundle is added (see UnitCountBasedUpkeepCampaignEffectsBundleAwarded).
local function fix_dummy_upkeep_effect_bundle(do_not_retry)
local uic_dummy_upkeep_effect_bundle = find_uicomponent(core:get_ui_root(), "layout", "resources_bar", "topbar_list_parent", "global_effect_list", config.dummy_upkeep_effect_bundle)
if not uic_dummy_upkeep_effect_bundle then
if not do_not_retry then
-- If effect bundle was just applied, the UIC for it might not be created yet, so wait a 'tick' and retry
cm:callback(function() fix_dummy_upkeep_effect_bundle() end, 0)
end
return
end
-- region_info_pip used here is just a simple dummy template that can be rejiggered into an icon UIC - inspired from the UIMF.
local uic_dummy_upkeep_effect_bundle_icon, was_created = core:get_or_create_component(dummy_upkeep_effect_bundle .. "_icon", "ui/campaign ui/region_info_pip", uic_dummy_upkeep_effect_bundle)
if was_created then
utils.uic_resize(uic_dummy_upkeep_effect_bundle_icon, 27, 29)
local pos_x, _ = uic_dummy_upkeep_effect_bundle:Position()
uic_dummy_upkeep_effect_bundle_icon:MoveTo(pos_x, 2)
uic_dummy_upkeep_effect_bundle_icon:SetImage("ui/campaign ui/effect_bundles/variable_upkeep.png")
uic_dummy_upkeep_effect_bundle_icon:PropagatePriority(uic_dummy_upkeep_effect_bundle:Priority())
out("UnitCountBasedUpkeep: fix_dummy_upkeep_effect_bundle: " .. uicomponent_to_str(uic_dummy_upkeep_effect_bundle_icon) .. " created")
else
out("UnitCountBasedUpkeep: fix_dummy_upkeep_effect_bundle: " .. uicomponent_to_str(uic_dummy_upkeep_effect_bundle_icon) .. " already created")
end
end
-- Faction-wide effect bundle icons are ordered in the top bar by appearance order. The upkeep icon should always appear last, so remove & re-add the dummy upkeep effect bundle if needed.
-- There is also workaround for our dummy upkeep effect bundle 'fix' being undone whenever a new visible faction-wide effect bundle is added, due to the layout regenerating the top bar.
-- The solution is to simply reapply the 'fix'.
-- Note: Unfortunately, this also happens when a faction-wide effect bundle is removed, but there's no event hook to listen on for that case.
core:add_listener(
"UnitCountBasedUpkeepCampaignEffectsBundleAwarded",
"CampaignEffectsBundleAwarded",
function(context)
if not custom_ui_listeners.enabled() then
return false
end
-- Only trigger during player turns, since the resources bar at the top that contains the faction effect bundles is hidden outside player turns anyway.
local faction = context:faction()
if faction:name() == faction:model():world():whose_turn_is_it():name() then
if is_valid_faction(faction) then
if faction:has_effect_bundle(dummy_upkeep_effect_bundle) then
return true
end
end
end
return false
end,
function(context)
local faction = context:faction()
local faction_name = faction:name()
out("UnitCountBasedUpkeepCampaignEffectsBundleAwarded: " .. faction_name)
if faction:has_effect_bundle(dummy_upkeep_effect_bundle) then
custom_ui_listeners.disable_during_call(function()
cm:remove_effect_bundle(dummy_upkeep_effect_bundle, faction_name)
cm:apply_effect_bundle(dummy_upkeep_effect_bundle, faction_name, 0)
end)
cm:callback(function() fix_dummy_upkeep_effect_bundle() end, 0) -- delay a 'tick' so that the effect bundle (which may not be the dummy one) appears
end
end,
true
)
-- If mouse is hovered over the top bar, player attention is probably focused there, so take the opportunity to apply the dummy upkeep effect bundle 'fix' if needed.
core:add_listener(
"UnitCountBasedUpkeepComponentMouseOnResourcesBar",
"ComponentMouseOn",
function(context)
if not custom_ui_listeners.enabled() then
return false
end
local uic = UIComponent(context.component)
return uicomponent_descended_from(uic, "resources_bar")
end,
custom_ui_listeners.enabled,
function(context)
out("UnitCountBasedUpkeepComponentMouseOn: " .. uicomponent_to_str(UIComponent(context.component)))
fix_dummy_upkeep_effect_bundle(true)
end,
true
)
-- TEMP?
--[[
core:add_listener(
"UnitCountBasedUpkeepPanelOpenedCampaign",
"PanelOpenedCampaign",
custom_ui_listeners.enabled,
function(context)
out("UnitCountBasedUpkeepPanelOpenedCampaign: " .. context.string)
cm:callback(function() fix_dummy_upkeep_effect_bundle(true) end, 0)
end,
true
)
--]]
-- TEMP?
--[[
core:add_listener(
"UnitCountBasedUpkeepPanelClosedCampaign",
"PanelClosedCampaign",
custom_ui_listeners.enabled,
function(context)
out("UnitCountBasedUpkeepPanelClosedCampaign: " .. context.string)
cm:callback(function() fix_dummy_upkeep_effect_bundle(true) end, 0)
end,
true
)
--]]
local function show_dummy_upkeep_effect_bundle(faction)
out("UnitCountBasedUpkeep: show_dummy_upkeep_effect_bundle for faction " .. faction:name())
if not faction:has_effect_bundle(dummy_upkeep_effect_bundle) then
custom_ui_listeners.disable_during_call(function()
cm:apply_effect_bundle(dummy_upkeep_effect_bundle, faction:name(), 0)
end)
end
fix_dummy_upkeep_effect_bundle() -- should apply this regardless since we could be loading a saved game
end
local function hide_dummy_upkeep_effect_bundle(faction)
out("UnitCountBasedUpkeep: hide_dummy_upkeep_effect_bundle for faction " .. faction:name())
if faction:has_effect_bundle(dummy_upkeep_effect_bundle) then
cm:remove_effect_bundle(dummy_upkeep_effect_bundle, faction:name())
end
end
local function update_dummy_upkeep_effect_bundle_visibility(faction)
---out("UnitCountBasedUpkeep: update_dummy_upkeep_effect_bundle_visibility...")
-- If # armies > 1, original supply lines dummy upkeep effect bundle is presumed to exist (or eventually will exist), so hide our custom dummy one if it exists.
-- Else, apply our own custom dummy one.
if factions_tracker:get_army_count(faction) > 1 then
hide_dummy_upkeep_effect_bundle(faction)
else
show_dummy_upkeep_effect_bundle(faction)
end
end
-- Computes the total increase in upkeep cost from our unit-count-based upkeep effect.
-- Note: This can't be cached, because there are insufficient events/hooks to catch every situation where the upkeep may change. In particular, we lack a hook for effect bundle removals.
local function get_upkeep_cost_increase(faction)
local faction_name = faction:name()
local upkeep_pct_details = get_upkeep_pct_details(faction)
out(string.format("UnitCountBasedUpkeep: upkeep_pct = min(%d, round(max(0, %d - %d) * %d / %d)) = %d%s",
config.max_upkeep_pct, upkeep_pct_details.num_units, config.num_free_units, upkeep_pct_details.orig_upkeep_pct_per_army, config.max_num_units_per_army, upkeep_pct_details.upkeep_pct,
upkeep_pct_details.is_dummy_upkeep_pct and " (dummy)" or ""))
local upkeep_effect_bundle = config.upkeep_effect_bundle_prefix .. upkeep_pct_details.upkeep_pct
return custom_ui_listeners.disable_during_call(function()
-- Since agent upkeep is currently unaffected by upkeep mods, their difference in upkeep cost is always 0. So we only need to get the difference between total army upkeeps.
local upkeep_cost_with_effect = factions_tracker:get_total_army_upkeep(faction, utils.always_true)
out("UnitCountBasedUpkeep: upkeep_cost_with_effect = " .. upkeep_cost_with_effect)
cm:remove_effect_bundle(upkeep_effect_bundle, faction_name)
local upkeep_cost_without_effect = factions_tracker:get_total_army_upkeep(faction, utils.always_true)
out("UnitCountBasedUpkeep: upkeep_cost_without_effect = " .. upkeep_cost_without_effect)
cm:apply_effect_bundle(upkeep_effect_bundle, faction_name, 0)
return upkeep_cost_with_effect - upkeep_cost_without_effect
end)
end
local current_upkeep_pct_save_key_prefix = config.army_unit_count_prefix .. "current_upkeep_pct_"
local function update_army_upkeep_effect_bundle(faction)
local faction_name = faction:name()
out("UnitCountBasedUpkeep: update_army_upkeep_effect_bundle for " .. faction_name)
local upkeep_pct = get_upkeep_pct(faction)
local upkeep_effect_bundle = config.upkeep_effect_bundle_prefix .. upkeep_pct
local save_key = current_upkeep_pct_save_key_prefix .. faction_name
local current_upkeep_pct = cm:get_saved_value(save_key)
if current_upkeep_pct == nil then
out("UnitCountBasedUpkeep: no army upkeep saved value found - new game or existing save without UnitCountBasedUpkeep mod enabled")
if not faction:has_effect_bundle(upkeep_effect_bundle) then
cm:apply_effect_bundle(upkeep_effect_bundle, faction_name, 0)
else
out("UnitCountBasedUpkeep: unexpectedly found army upkeep penalty effect already applied; scanning to ensure no other army upkeep penalty effects applied")
for i = 0, config.max_upkeep_pct do
local effect_bundle_i = config.upkeep_effect_bundle_prefix .. i
if i ~= upkeep_pct then
if faction:has_effect_bundle(effect_bundle_i) then
out("UnitCountBasedUpkeep: unexpectedly found extraneous army upkeep penalty effect - removing")
cm:remove_effect_bundle(effect_bundle_i, faction_name)
end
end
end
end
else
if current_upkeep_pct ~= upkeep_pct then
cm:remove_effect_bundle(config.upkeep_effect_bundle_prefix .. current_upkeep_pct, faction_name)
cm:apply_effect_bundle(upkeep_effect_bundle, faction_name, 0)
else
out("UnitCountBasedUpkeep: no change in army upkeep penalty")
end
end
cm:set_saved_value(save_key, upkeep_pct)
return upkeep_effect_bundle
end
local update_army_upkeep_singleton_callback_name_prefix = "UnitCountBasedUpkeep_callback_"
-- Updates the army upkeep penalty by refreshing faction army & unit counts, updating dummy effect bundle icon visibility, and updating the actual upkeep effect bundle.
local function update_army_upkeep_penalty(faction, delay_first_call, success_callback, failure_callback)
local faction_name = faction:name()
local callback_name = update_army_upkeep_singleton_callback_name_prefix .. faction_name
out(string.format("UnitCountBasedUpkeep: update_army_upkeep_penalty(%s, %s, %s, %s)", faction_name, tostring(delay_first_call), tostring(success_callback), tostring(failure_callback)))
-- Mechanism to reduce redundant calls, especially when multiple events that can affect unit counts fire consecutively (such as disbanding multiple units):
-- If delay_first_call is true, then the upkeep updating happens in a named callback. This callback is canceled whenever this function is called, before setting up the callback again.
-- Similarly, all retries to update_army_upkeep_effect_bundle below use the same callback name, so that even if delay_first_call is false, the retries will be canceled first,
-- before setting up update_army_upkeep_effect_bundle tries again.
-- In this way, the callback acts like a 'singleton' (per faction).
-- TODO: replace callback instead of removing/adding
cm:remove_callback(callback_name)
if delay_first_call then
cm:callback(function()
-- Note: context objects tend to be destroyed after the listener and thus cause crashes if used in a callback, so refetching objects here.
local callback_faction = utils.get_faction(faction_name)
update_army_upkeep_penalty(callback_faction, false, success_callback, failure_callback)
end, 0.1, callback_name)
return
end
factions_tracker:refresh(faction)
update_dummy_upkeep_effect_bundle_visibility(faction)
utils.retry_callback({
callback = function()
-- Note: context objects tend to be destroyed after the listener and thus cause crashes if used in a callback, so refetching objects here.
local callback_faction = utils.get_faction(faction_name)
return update_army_upkeep_effect_bundle(callback_faction)
end,
max_tries = 15,
base_delay = 0.1,
exponential_backoff = 1.3, -- sum of 0.1 * 1.3^(i-1) for i = 1 to 15 => ~16.73 secs
callback_name = callback_name,
success_callback = success_callback,
exhaust_tries_callback = failure_callback,
enable_logging = true,
})
end
-- Hack to force update the values in the treasury bar, namely its income value and its tooltip.
-- This involves opening and closing the finance panel at the bottom, so this should only be done when the panel at the bottom is currently unused for a more seamless UX.
function force_update_treasury_bar()
local uic_root = core:get_ui_root()
local uic_finance_screen = find_uicomponent(uic_root, "finance_screen")
if not uic_finance_screen then
custom_ui_listeners.disable_during_call(function()
local uic_button_finance = find_uicomponent(uic_root, "layout", "resources_bar", "topbar_list_parent", "treasury_holder", "dy_treasury", "button_finance")
uic_button_finance:ClearSound() -- prevent finance button from playing sound
uic_button_finance:SimulateLClick() -- open finance panel
uic_button_finance:SimulateLClick() -- close finance panel
end)
out("UnitCountBasedUpkeep: force_update_treasury_bar")
else
-- Shouldn't need to do anything
end
end
-- Apply the effect bundles every time the player turn starts, including the new game case (i.e. not loading a save).
-- This should also units being destroyed due to attrition which happens right before turn start.
core:add_listener(
"UnitCountBasedUpkeepFactionTurnStart",
"FactionTurnStart",
function(context)
return is_valid_faction(context:faction())
end,
function(context)
local faction = context:faction()
out("UnitCountBasedUpkeepFactionTurnStart: " .. utils.campaign_obj_to_string(faction))
update_army_upkeep_penalty(faction)
end,
true
)
-- Remove the original army-count-based upkeep listeners that are added at first tick.
-- Following first tick callback should happen after the one that adds those listeners.
-- Also take the opportunity to remove any existing original army-count-based upkeep effect bundles.
cm:add_first_tick_callback(function(context)
out("UnitCountBasedUpkeep: removing original upkeep listeners and effect bundles")
core:remove_listener("player_army_turn_start_listener")
core:remove_listener("player_army_created_listener")
core:remove_listener("confederation_player_army_count_listener")
local human_faction_names = cm:get_human_factions()
for i = 1, #human_faction_names do
local faction = utils.get_faction(human_faction_names[i])
if is_valid_faction(faction) then
local mf_list = faction:military_force_list()
for j = 1, mf_list:num_items() - 1 do -- mf_list is 0-indexed, and explicitly ignoring the first army since it shouldn't have effect applied to it
local mf = mf_list:item_at(j)
if is_valid_army(mf) then
for difficulty_level = 1, -3, -1 do
local effect_bundle = orig_upkeep_pct_per_army_calc:get_effect_bundle(difficulty_level)
if mf:has_effect_bundle(effect_bundle) then
cm:remove_effect_bundle_from_characters_force(effect_bundle, mf:general_character():cqi())
end
end
end
end
end
end
end)
-- Apply the effect bundles ASAP (FirstTickAfterWorldCreated event works well enough) in the case of loading a save, where the player turn start event won't be triggered.
-- Note that this can't be done in the LoadingGame event since that happens too early, before the game/UI is created.
-- On the other hand, the FirstTickAfterWorldCreated event is guaranteed to happen after the game/UI is created.
cm:add_first_tick_callback(function(context)
out("UnitCountBasedUpkeep: first tick")
if not cm:is_new_game() then
local faction = context:world():whose_turn_is_it()
if is_valid_faction(faction) then
update_army_upkeep_penalty(faction)
end
end
end)
-- The last FactionTurnEnd is the final guaranteed moment when we can update faction army/unit counts before upkeep/income is applied for the next round.
-- Assume that the rebel faction (CQI 1) always exists and always is the last faction to turn before the round ends.
core:add_listener(
"UnitCountBasedUpkeepLastFactionTurnEnd",
"FactionTurnEnd",
function(context)
return context:faction():command_queue_index() == 1 -- rebel faction
end,
function(context)
out("UnitCountBasedUpkeepLastFactionTurnEnd: " .. utils.campaign_obj_to_string(context:faction()))
local human_faction_names = cm:get_human_factions()
for i = 1, #human_faction_names do
local faction = utils.get_faction(human_faction_names[i])
if is_valid_faction(faction) then
update_army_upkeep_penalty(faction)
end
end
end,
true
)
-- TODO UnitCountBasedUpkeepMilitaryForceCreated/UnitCountBasedUpkeepScriptedForceCreated/UnitCountBasedUpkeepFactionJoinsConfederation below
-- may not be necessary due to UnitCreated also being fired, though UnitCreated call to update_army_upkeep_penalty is delayed...
-- Recalc and reapply the effect bundles every time the player creates a new force (and hires a lord)
core:add_listener(
"UnitCountBasedUpkeepMilitaryForceCreated",
"MilitaryForceCreated", -- fires when lord is hired normally, does NOT fire for cm:create_force*
function(context)
return is_valid_faction(context:military_force_created():faction())
end,
function(context)
local faction = context:military_force_created():faction()
local debug_obj_str = utils.campaign_obj_to_string(faction)
out("UnitCountBasedUpkeepMilitaryForceCreated: " .. debug_obj_str)
update_army_upkeep_penalty(faction)
end,
true
)
-- ScriptedForceCreated is fired when cm:create_force* finishes creating a new force, but the event context is empty, so there's no way to find the faction/force/character created.
-- The workaround is to wrap cm:force_created to intercept the passed faction name/key.
local orig_cm_force_created = cm.force_created
function cm.force_created(self, id, listener_name, faction_key, ...)
local ret_val = orig_cm_force_created(self, id, listener_name, faction_key, ...)
local faction = utils.get_faction(faction_key)
if is_valid_faction(faction) then
local debug_obj_str = utils.campaign_obj_to_string(faction)
out("UnitCountBasedUpkeepScriptedForceCreated: " .. debug_obj_str)
update_army_upkeep_penalty(faction)
end
return ret_val
end
-- Recalc and reapply the effect bundles every time the player confederates
core:add_listener(
"UnitCountBasedUpkeepFactionJoinsConfederation",
"FactionJoinsConfederation",
function(context)
return is_valid_faction(context:confederation())
end,
function(context)
local faction = context:confederation()
out("UnitCountBasedUpkeepFactionJoinsConfederation: " .. utils.campaign_obj_to_string(faction))
-- TODO: wait for diplomacy_dropdown panel to close if it's open
update_army_upkeep_penalty(faction, false, function() -- success callback
force_update_treasury_bar() -- since it doesn't update on its own for some reason (vanilla bug)
end)
end,
true
)
core:add_listener(
"UnitCountBasedUpkeepUnitCreated",
"UnitCreated",
function(context)
-- Only include units that are created during player's turn, since units that are trained by x turn are created before the FactionTurnStart for x,
-- and thus shouldn't count toward upkeep that's applied at FactionRoundStart (which takes place before all factions' FactionTurnStart for the round).
local faction = context:unit():faction()
if faction:name() == faction:model():world():whose_turn_is_it():name() then
if is_valid_faction(faction) then
-- For some reason, unit:military_force() crashes the game during this event, so the following check needs to happen in a callback
-- if is_valid_army(unit:military_force())
return true
end
end
return false
end,
function(context)
local unit = context:unit()
out("UnitCountBasedUpkeepUnitCreated: " .. utils.campaign_obj_to_string(unit))
-- Reason for delay_first_call=true in following call:
-- In the common case of multiple units being created at once, keep delaying (and canceling previous delayed update_army_upkeep_penalty's),
-- so that the meat of update_army_upkeep_penalty fires only once.
update_army_upkeep_penalty(unit:faction(), true)
end,
true
)
--[[
-- TEMP?
core:add_listener(
"UnitCountBasedUpkeepUnitTrained",
"UnitTrained",
function(context)
local unit = context:unit()
return is_valid_faction(unit:faction()) and is_valid_army(unit:military_force())
end,
function(context)
out("UnitCountBasedUpkeepUnitTrained: " .. campaign_obj_to_string(context:unit()))
end,
true
)
--]]
core:add_listener(
"UnitCountBasedUpkeepUnitDisbanded",
"UnitDisbanded",
function(context)
local unit = context:unit()
return is_valid_faction(unit:faction()) and is_valid_army(unit:military_force())
end,
function(context)
local unit = context:unit()
out("UnitCountBasedUpkeepUnitDisbanded: " .. utils.campaign_obj_to_string(unit))
-- Reason for delay_first_call=true in following call:
-- Disbanding unit still exists in the military force, so wait a bit so that force's # units actually decrements.
update_army_upkeep_penalty(unit:faction(), true)
end,
true
)
core:add_listener(
"UnitCountBasedUpkeepUnitMergedAndDestroyed",
"UnitMergedAndDestroyed",
function(context)
local unit = context:unit()
return is_valid_faction(unit:faction()) and is_valid_army(unit:military_force())
end,
function(context)
out("UnitCountBasedUpkeepUnitMergedAndDestroyed: " .. utils.campaign_obj_to_string(context:unit()))
end,
true
)
-- Listen to when an agent (non-embedded hero) spawns on the map
core:add_listener(
"UnitCountBasedUpkeepCharacterCreated",
"CharacterCreated",
function(context)
return is_valid_faction(context:character():faction())
end,
function(context)
local char = context:character()
out("UnitCountBasedUpkeepCharacterCreated: " .. utils.campaign_obj_to_string(char))
if not char:is_embedded_in_military_force() and cm:char_is_agent(char) then -- agent
update_army_upkeep_penalty(char:faction(), false, function() -- success callback
force_update_treasury_bar() -- since it doesn't update on its own for some reason (vanilla bug)
end)
end
end,
true
)
core:add_listener(
"UnitCountBasedUpkeepCharacterConvalescedOrKilled",
"CharacterConvalescedOrKilled",
function(context)
return is_valid_faction(context:character():faction())
end,
function(context)
local char = context:character()
out("UnitCountBasedUpkeepCharacterConvalescedOrKilled: " .. utils.campaign_obj_to_string(char))
if not char:is_embedded_in_military_force() and cm:char_is_agent(char) then -- agent
-- Reason for delay_first_call=true in following call:
-- Disbanding unit still exists in the military force, so wait a bit so that force's # units actually decrements
update_army_upkeep_penalty(char:faction(), true)
end
end,
true
)
core:add_listener(
"UnitCountBasedUpkeepBattleCompleted",
"BattleCompleted",
true,
function(context)
out("UnitCountBasedUpkeepBattleCompleted")
-- Get set of unique faction names involved from the pending battle cache.
local faction_names = {}
for i = 1, cm:pending_battle_cache_num_attackers() do
local faction_name = cm:pending_battle_cache_get_attacker_faction_name(i)
faction_names[faction_name] = true
end
for i = 1, cm:pending_battle_cache_num_defenders() do
local faction_name = cm:pending_battle_cache_get_defender_faction_name(i)
faction_names[faction_name] = true
end
-- Update all upkeep-applicable factions involved.
local last_ret_status, last_ret_value = true, nil
for faction_name, _ in pairs(faction_names) do
local faction = utils.get_faction(faction_name)
if is_valid_faction(faction) then
last_ret_status, last_ret_value = pcall(update_army_upkeep_penalty, faction)
end
end
if not last_ret_status then
error(last_ret_value)
end
end,
true
)
--[[
-- TEMP?
core:add_listener(
"UnitCountBasedUpkeepCharacterCharacterTargetAction",
"CharacterCharacterTargetAction",
true,
function(context)
local char, target_char = context:character(), context:target_character()
if is_valid_faction(char:faction()) and char:is_wounded() then -- aka critical failure
out("UnitCountBasedUpkeepCharacterCharacterTargetAction: source wounded: " .. utils.campaign_obj_to_string(char))
elseif is_valid_faction(target_char:faction()) and context:mission_result_success() then
-- Note: Can't use Character:is_wounded in above check since that doesn't account for assassinations, so using mission_result_success has a workaround.
if char:faction():name() == target_char:faction():name() then -- if same faction
out("UnitCountBasedUpkeepCharacterCharacterTargetAction: source joins target\n\tsource: " .. utils.campaign_obj_to_string(char) ..
"\n\ttarget: " .. utils.campaign_obj_to_string(target_char))
else
out("UnitCountBasedUpkeepCharacterCharacterTargetAction: target wounded/killed: " .. utils.campaign_obj_to_string(target_char))
end
end
end,
true
)
-- TEMP?
core:add_listener(
"UnitCountBasedUpkeepCharacterGarrisonTargetAction",
"CharacterGarrisonTargetAction",
function(context)
return is_valid_faction(context:character():faction()) and context:character():is_wounded() -- aka critical failure
end,
function(context)
out("UnitCountBasedUpkeepCharacterGarrisonTargetAction: source wounded: " .. utils.campaign_obj_to_string(context:character()))
end,
true
)
--]]
-- Recalc and reapply effect bundles whenever difficulty changes (should only apply in singleplayer)
core:add_listener(
"UnitCountBasedUpkeepNominalDifficultyLevelChangedEvent",
"NominalDifficultyLevelChangedEvent",
true,
function(context)
local model = context:model()
out("NominalDifficultyLevelChangedEvent: " .. model:combined_difficulty_level())
orig_upkeep_pct_per_army_calc:reset()
local faction = model:world():faction_by_key(cm:get_local_faction(true))
update_army_upkeep_penalty(faction, false, function() -- success callback
force_update_treasury_bar() -- since it doesn't update on its own for some reason (vanilla bug)
end)
end,
true
)
-- Custom effect bundle tooltip mechanism
-- %d (%d discounted for free)
local tooltip_num_units_format = effect.get_localised_string("ui_text_replacements_localised_text_tooltip_lbm_additional_army_unit_count_upkeep_num_units")
-- %d%% (%.2f%% per unit × %d units = %.2f%%)
local tooltip_upkeep_upkeep_percent_format = effect.get_localised_string("ui_text_replacements_localised_text_tooltip_lbm_additional_army_unit_count_upkeep_upkeep_percent")
-- %d%%
local tooltip_upkeep_dummy_upkeep_percent_format = effect.get_localised_string("ui_text_replacements_localised_text_tooltip_lbm_additional_army_unit_count_upkeep_dummy_upkeep_percent")
-- Put anything that that has the potential to effect the model (such as the effect bundle applying that can be done in factions_tracker:get_unit_count and get_upkeep_cost_increase) here.
-- This should ensure that the game model is synced between multiple players (i.e. prevent MP desyncs) when the various temporary model changes are done to compute required values.
-- This listener is triggered from the below ComponentMouseOn listener, and this trigger conveniently happens soon (if not immediately) after that listener finishes handling its event.
-- Also, for some reason, for the actual upkeep effect bundle (when >1 armies), the upkeep tooltip can be overwritten with original army-count-based values right after the
-- ComponentMouseOn listener runs, and I can find no event triggers that correspond to this. Workaround is to wait a 'tick' and reset the tooltip to use our unit-count-based values.
-- The soonest this tick can happen is via a triggered UITriggerScriptEvent, which occurs even before the 0.0 (0.1) second callback.
utils.add_custom_ui_event_listener("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent", function(faction_cqi, tooltip_root_id, max_tries)
-- Abort/retry if tooltip_campaign_upkeep_effect is no longer open for whatever reason
local uic_root = core:get_ui_root()
local uic_campaign_upkeep_tooltip = find_uicomponent(uic_root, "tooltip_campaign_upkeep_effect")
if not uic_campaign_upkeep_tooltip then
if max_tries > 1 then
utils.trigger_custom_ui_event("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent", faction_cqi, tooltip_root_id, max_tries - 1)
end
return
end
local uic_tooltip_root = uic_campaign_upkeep_tooltip
if tooltip_root_id ~= "tooltip_campaign_upkeep_effect" then
uic_tooltip_root = find_uicomponent(uic_root, tooltip_root_id)
if not uic_tooltip_root then
if max_tries > 1 then
utils.trigger_custom_ui_event("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent", faction_cqi, tooltip_root_id, max_tries - 1)
end
return
end
end
--out("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent: uic_campaign_upkeep_tooltip: " .. uicomponent_to_str(uic_campaign_upkeep_tooltip))
--out("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent: uic_tooltip_root: " .. uicomponent_to_str(uic_tooltip_root))
local faction = utils.get_faction(faction_cqi)
local upkeep_pct_details = get_upkeep_pct_details(faction)
local upkeep_cost_increase = get_upkeep_cost_increase(faction)
out(string.format("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent: faction=%s, # units=%d, upkeep %%=%d%s, upkeep %%/unit=%.2f%%, upkeep cost increase=%d",
faction:name(), upkeep_pct_details.num_units, upkeep_pct_details.upkeep_pct,
upkeep_pct_details.is_dummy_upkeep_pct and " (dummy)" or "",
upkeep_pct_details.upkeep_pct_per_unit, upkeep_cost_increase))
local num_units_text = tooltip_num_units_format:format(upkeep_pct_details.num_units, config.num_free_units)
local upkeep_percent_format = upkeep_pct_details.is_dummy_upkeep_pct and tooltip_upkeep_dummy_upkeep_percent_format or tooltip_upkeep_upkeep_percent_format
local upkeep_pct_text = upkeep_percent_format:format(upkeep_pct_details.upkeep_pct, upkeep_pct_details.upkeep_pct_per_unit, upkeep_pct_details.num_unfree_units, upkeep_pct_details.raw_upkeep_pct)
local upkeep_cost_increase_text = tostring(upkeep_cost_increase)
local uic_campaign_upkeep_tooltip_list = find_uicomponent(uic_campaign_upkeep_tooltip, "list_parent")
find_uicomponent(uic_campaign_upkeep_tooltip_list, "label_armies_parent", "label_num_armies"):SetStateText(num_units_text)
find_uicomponent(uic_campaign_upkeep_tooltip_list, "label_upkeep_percent_parent", "label_percent_increase"):SetStateText(upkeep_pct_text)
find_uicomponent(uic_campaign_upkeep_tooltip_list, "label_upkeep_cost_parent", "label_cost_increase"):SetStateText(upkeep_cost_increase_text)
uic_tooltip_root:SetVisible(true)
if tooltip_root_id ~= "tooltip_campaign_upkeep_effect" then
uic_campaign_upkeep_tooltip:SetVisible(true)
end
out("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent: tooltip_campaign_upkeep_effect values set")
end)
core:add_listener(
"UnitCountBasedUpkeepEffectTooltip",
"ComponentMouseOn",
custom_ui_listeners.enabled,
function(context)
local uic = UIComponent(context.component)
local uic_id = uic:Id()
--out("UnitCountBasedUpkeepEffectTooltip: " .. uicomponent_to_str(uic))
if orig_upkeep_pct_per_army_calc:is_effect_bundle(uic_id) or is_dummy_upkeep_effect_bundle(uic_id) then
local uic_root = core:get_ui_root()
-- Ensure that the tooltip_campaign_upkeep_effect tooltip is open, yet hidden for the time being.
local uic_campaign_upkeep_tooltip = find_uicomponent(uic_root, "tooltip_campaign_upkeep_effect")
local tooltip_root_id = "tooltip_campaign_upkeep_effect" -- since the actual tooltip root can be TechTooltipPopup instead (see below)
local max_tries = 1
if not uic_campaign_upkeep_tooltip then
if is_dummy_upkeep_effect_bundle(uic_id) then
-- Wait for the normal effect bundle tooltip (TechTooltipPopup) to be created for the dummy upkeep effect bundle.
local uic_tooltip_root = find_uicomponent(uic_root, "TechTooltipPopup")
if not uic_tooltip_root then
-- SimulateMouseOn() to synchronously force the tooltip to be generated if it hasn't been yet, while avoiding triggering this listener again.
custom_ui_listeners.disable_during_call(function()
uic:SimulateMouseOn()
end)
uic_tooltip_root = find_uicomponent(uic_root, "TechTooltipPopup")
end
-- Hide this tooltip until UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent fires (see below for trigger) and shows it.
-- This should hide the just-created tooltip before it even appears in the first place.
-- Note: we can't just set this invisible while having the child tooltip component (see below tooltip_campaign_upkeep_effect) visible,
-- since it seems the parent UI component's visibility takes precedence.
uic_tooltip_root:SetVisible(false)
-- Try to prevent the parent TechTooltipPopup tooltip from showing its contents and border when it does become shown.
-- The following doesn't actually fully make it transparent, but it seems to hide it sufficiently when the child tooltip_campaign_upkeep_effect (see below) is shown.
uic_tooltip_root:DestroyChildren()
uic_tooltip_root:SetImage("ui/skins/default/1x1_transparent_white.png")
-- Create the tooltip_campaign_upkeep_effect tooltip, and make it the only child of the otherwise empty TechTooltipPopup tooltip.
-- This ties the lifecycle of the former to the latter, such that when the tooltip is normally removed on mouse out, tooltip_campaign_upkeep_effect also gets removed.
-- This is necessary since there's no reliable mouse out event that we can attach a listener to, because not everything on the screen is a UI component
-- that would have ComponentMouseOn triggered on them.
uic_campaign_upkeep_tooltip = core:get_or_create_component("tooltip_campaign_upkeep_effect", "UI/common ui/tooltip_campaign_upkeep_effect", uic_tooltip_root)
uic_tooltip_root:Adopt(uic_campaign_upkeep_tooltip:Address()) -- this is somehow different from just creating the tooltip UIC as a child of uic_tooltip_root
tooltip_root_id = uic_tooltip_root:Id()
out("UnitCountBasedUpkeepEffectTooltip: tooltip_campaign_upkeep_effect created")
else -- if orig_upkeep_pct_per_army_calc:is_effect_bundle(uic_id)
-- XXX: tooltip_campaign_upkeep_effect never exists by ComponentMouseOn, and when it does appear moments later, it always has default army-count-based values.
-- Similarly, if we call SimulateMouseOn(), tooltip_campaign_upkeep_effect does appear (by then?), but moments later, it gets reset to its default army-count-based values.
-- This unfortunately means that even if we get tooltip_campaign_upkeep_effect to exist by now and update its values* or is hidden, it will get appear reset momentarily later.
-- * ...which is a moot point, since it needs to be delayed until UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent to prevent multiplayer desyncs.
-- The tooltip seems to get updated with its defaults values before the triggered (see below) UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent fires,
-- so there's a split second of time, where tooltip_campaign_upkeep_effect will appear with default values, and I can't find any way to fully solve this.
-- (I tried tracking all event handlers/listeners/timers via lbm_events_tracker.lua but to no avail.)
out("UnitCountBasedUpkeepEffectTooltip: tooltip_campaign_upkeep_effect should exist but doesn't exist yet")
-- tooltip_campaign_upkeep_effect should appear before UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent fires, but add retries just in case.
max_tries = 3
end
else
-- See above comment about the timing issues of the actual tooltip_campaign_upkeep_effect and its default values.
-- Also don't bother trying to hide it if it's already open, since it'll just cause a flicker.
out("UnitCountBasedUpkeepEffectTooltip: tooltip_campaign_upkeep_effect already opened - no need to create")
end
local faction = utils.get_faction(cm:get_local_faction(true))
utils.trigger_custom_ui_event("UnitCountBasedUpkeepEffectTooltipUITriggerScriptEvent", faction:command_queue_index(), tooltip_root_id, max_tries)
end
end,
true
)
out("UnitCountBasedUpkeep: setup done")
|
local obj = require 'core.obj'
local Sprite = require 'type.graphics.Sprite'
local ItemRegistry = obj.new('ItemRegistry', function(self, image, quantity, offset_x, offset_y, frame_width, frame_height, frame_spacing_x, frame_spacing_y)
self.sprite = Sprite(image)
self.sprite:loadFrames(
quantity,
offset_x, offset_y,
frame_width, frame_height,
frame_spacing_x, frame_spacing_y)
self.registry = {}
self.current_id = 1
self.icon_table = {}
end)
function ItemRegistry:registerItemPrototype(frame_index, name, type, survival, abilities, uses)
local ItemPrototype = obj.new('Item.'..name, function(self, registry)
self.registry = registry
self.prototype = {
icon = frame_index,
name = name,
type = type,
survival = survival,
abilities = abilities,
uses = uses
}
end))
self.registry[self.current_id] = ItemPrototype
self.current_id = self.current_id + 1
return self.current_id - 1
end |
----------------------------Aliases----------------------------
local key = vim.api.nvim_set_keymap
local remap = { noremap = true, silent = true }
---------------------------Leader Keys---------------------------
-- Set with normal Vim opts, 'Space' as mapleader
vim.g.mapleader = ' '
-- Set 'Space' as <NOP> key to leadermap key
key('n', '<Space>', '<NOP>', remap )
-- Find recursively TODOs, NOTEs, FIXITs, ... across the root folder subfiles.
key('n', '<Leader>l', ':TodoTelescope<CR>', remap )
-- Find recursively files across the root folder subfiles.
key('n', '<Leader>ff', ':lua require("telescope.builtin").find_files()<cr>', remap )
-- Find recursively a text across the root folder subfiles.
key('n', '<Leader>fg', ':lua require("telescope.builtin").live_grep()<cr>', remap )
-- Go to the next block.
--key('n', '<C-Down>', 'g%', remap )
-- Loop through brackets blocks.
--key('n', '<C-Up>', 'z%', remap )
-- Do just End on CTRL + End.
key('i', '<C-End>', '<End>', remap )
key('n', '<C-End>', '<End>', remap )
-- Do just Home on CTRL + Home.
key('i', '<C-Home>','<End>', remap )
-- Highlight the word after pressing enter.
key('n', '<CR>',
[[:let searchTerm = '\v<'.expand("<cword>").'>' <bar> let @/ = searchTerm <bar> echo '/'.@/ <bar> call histadd("search", searchTerm) <bar> set hls<cr>]],
remap )
-- Highlight the visual selection after pressing enter.
key('v', '<CR>',
[["*y:silent! let searchTerm = '\V'.substitute(escape(@*, '\/'), "\n", '\\n', "g") <bar> let @/ = searchTerm <bar> echo '/'.@/ <bar> call histadd("search", searchTerm) <bar> set hls<cr>]],
remap )
-- Highlight the visual selection after pressing '.
-- key('v', "'",
-- [[y/\V<C-R>=escape(@",'\\')<CR><CR>]],
-- remap )
-- Go to the next tab.
key('i', '<A-TAB>', '<c-o>:tabNext<CR>', remap)
key('n', '<A-TAB>', ':tabNext<CR>', remap)
-- Go to next tab (buffer).
key('n', '<TAB>', ':BufferLineCycleNext<CR>', remap )
-- Go to previous tab (buffer).
key('n', '<S-TAB>', ':BufferLineCyclePrev<CR>', remap )
-- To delete current buffer.
key('n', '<Leader>x', ':Bdelete<CR>', remap )
-- Just leave without saving.
key('n', '<Leader>qq', ':q<CR>', remap )
-- Toggle highlight of search
key('n', '<C-c>', ':set hlsearch!<CR>', remap )
-- Toggle the sidebar tree of the root folder.
key('n', '<Leader>e', ":Neotree toggle source=filesystem position=left<CR>:echo ''<CR>", remap )
-- Writing mode with zen.
key('n', '<Leader>z', ':ZenMode<CR>', remap )
-- Close block-only highlighting mode.
key('n', '<Leader>t', ':Twilight<CR>', remap )
-- Open n³ file explorer.
-- key('n', '<Leader>n', ':NnnPicker %:p:h<CR>', remap )
-- Try to correct the current word.
key('i', '<C-b>', 'ea<C-x><C-s>', remap )
-- Toggle built-in nvim spell checking.
key('n', '<F5>', ':setlocal spell!<CR>', remap )
-- Move lines normally like an IDE when line wraps
--key('i', '<Down>', [[v:count ? 'j' : '<c-o>gj']], { expr = true, noremap = true, silent = true })
--key('i', '<Up>', [[v:count ? 'k' : '<c-o>gk']], { expr = true, noremap = true, silent = true })
--key('n', '<Down>', [[v:count ? 'j' : 'gj']], { expr = true, noremap = true, silent = true })
--key('n', '<Up>', [[v:count ? 'k' : 'gk']], { expr = true, noremap = true, silent = true })
-- Set 'CTRL + v' as 'paster'
-- key('', '<C-v>', 'map"_d<Esc>i', remap )
key('v', '<C-v>', 'p', remap )
-- Set 'CTRL + x' as 'cut'
key('v', '<C-x>', 'mad`ai<Right>', { silent = true })
-- Set 'CTRL + c' as 'copier'
key('v', '<C-c>', 'may`ai', remap )
key('i', '<C-v>', '<Esc>:Registers<CR>', remap )
-- Create mark.
key('n', "'", '`', remap )
-- Move normaly bottom and up with C+Up and C+Down.
key('i', '<C-Up>', '<C-o>gk', remap )
key('i', '<C-Down>', '<C-o>gj', remap )
key('n', '<C-Up>', 'gk', remap )
key('n', '<C-Down>', 'gj', remap )
-- Set 'CTRL + z' as 'undo'
key('i', '<C-z>', '<Esc>ui', remap )
-- Set 'CTRL + y' as 'redo'
key('i', '<C-y>', '<Esc><C-r>', remap )
-- Set 'SHIFT + arrows' as 'select' like modern text-editor.
key('n', '<S-Up>', 'v<Up>', remap )
key('n', '<S-Down>', 'v<Down>', remap )
key('n', '<S-Left>', 'v<Left>', remap )
key('n', '<S-Right>', 'v<Right>', remap )
key('v', '<S-Up>', '<Up>', remap )
key('v', '<S-Down>', '<Down>', remap )
key('v', '<S-Left>', '<Left>', remap )
key('v', '<S-Right>', '<Right>', remap )
key('i', '<S-Up>', '<Esc>v<Up>', remap )
key('i', '<S-Down>', '<C-o>v<Down>', remap )
key('i', '<S-Left>', '<Esc>v<Left>', remap )
key('i', '<S-Right>', '<C-o>v<Right>', remap )
-- Set 'SHIFT + special-keys' as 'select' like a moden text editor.
key('i', '<S-Home>', '<Esc>v<Home>', remap )
key('i', '<S-End>', '<C-o>v<End><Left>', remap )
key('n', '<S-Home>', 'v<Home>', remap )
key('n', '<S-End>', 'v<End>', remap )
key('n', '<S-PageUp>', '<Esc>:call Visual_Scroll_Up()<CR>i<Right><Left>', remap )
key('n', '<S-PageDown>', '<Esc>:call Visual_Scroll_Down()<CR>i<Right><Left>', remap )
-- Set a nice Page-Arrow transition.
key('i', '<PageUp>', '<Esc>:call Insert_Scroll_Up()<CR>i', remap )
key('i', '<PageDown>', '<Esc>:call Insert_Scroll_Down()<CR>i', remap )
key('i', '<S-PageUp>', '<Esc>:call Visual_Scroll_Up()<CR>i<Right><Left>', remap )
key('i', '<S-PageDown>', '<Esc>:call Visual_Scroll_Down()<CR>i<Right><Left>', remap )
-- Indent the current visual selection.
key('v', '<', '<gv', remap )
key('v', '>', '>gv', remap )
-- Set 'Backspace' as 'delete selection' for the visual selection.
key('v', '<BS>', '"_di', remap )
-- Set 'F36 + F35' as 'delete word' in Insert mode, specific for my build of Simple Terminal (suckless) called flarity.
key('i', '<F36><F35>', '<C-w>', remap )
|
require("ElementManager")
require("SkillManager")
require("CoRunner")
Container = {}
function Container:New(elementId, core)
local o = {}
setmetatable(o, self)
self.__index = self
o.id = elementId
o.core = core
o.ElementMass = 0
o.Capacity = 0
o.Name = "<Unknown>"
o.ReducedContentMass = 0
o.ActualContentMass = 0
o.ContentVolume = 0
o:update()
return o
end
function Container:update()
self:updateBaseData()
-- The mass we get here is adjusted for skills applied to the container.
self.ReducedContentMass = self.core.getElementMassById(self.id) - self.ElementMass
skill = SkillManager:Instance()
self.ActualContentMass = skill:CalculateActualMass(self.ReducedContentMass)
end
function Container:updateBaseData()
local core = self.core
local maxHitPoints = core.getElementMaxHitPointsById(self.id)
skill = SkillManager:Instance()
if maxHitPoints >= 69267 then
-- XXL
self.ElementMass = 884013
self.Capacity = skill:ApplyContainerProficency(512000)
elseif maxHitPoints >= 34633 then
-- XL
self.ElementMass = 44206
self.Capacity = skill:ApplyContainerProficency(256000)
elseif maxHitPoints >= 17316 then
-- L
self.ElementMass = 14842.7
self.Capacity = skill:ApplyContainerProficency(128000)
elseif maxHitPoints >= 7997 then
-- M
self.ElementMass = 7421.35
self.Capacity = skill:ApplyContainerProficency(64000)
elseif maxHitPoints >= 999 then
-- S
self.ElementMass = 1281.31
self.Capacity = skill:ApplyContainerProficency(8000)
else
-- xs
self.ElementMass = 229.09
self.Capacity = skill:ApplyContainerProficency(1000)
end
self.Name = core.getElementNameById(self.id)
return o
end
function Container:ToString()
local s = self.Name .. ": " .. self.Capacity .. "L" ..
" Element mass: " .. self.ElementMass .. "kg, Reduced Content mass: " .. self.ReducedContentMass ..
" Actual Content Mass: " .. self.ActualContentMass
return s
end
function Container:ItemCount(weightOfOneItem)
return self.ActualContentMass / weightOfOneItem
end
function Container:ItemVolume(volumeOfOneItem, weightOfOneItem)
local count = self:ItemCount(weightOfOneItem)
return count * volumeOfOneItem
end
function Container:FillFactor(volumeOfOneItem, weightOfOneItem)
local contentVolume = self:ItemVolume(volumeOfOneItem,weightOfOneItem)
return contentVolume / self.Capacity
end
ContainerManager = {}
function ContainerManager:New()
local o = {}
setmetatable(o, self)
self.__index = self
self.containersByName = {}
self.complete = false
return o
end
function ContainerManager:BeginUpdate()
CoRunner:Instance():Execute(
function()
local core = ElementManager:Instance().Core
local element_ids = core.getElementIdList()
for _, id in pairs(element_ids) do
if core.getElementTypeById(id) == "Container" then
local c = Container:New(id, core)
self.containersByName[c.Name] = c
end
end
table.sort(self.containersByName,
function (a, b) return string.lower(a.Name) < string.lower(b.Name) end)
end,
function()
self.complete = true
end)
end
function ContainerManager:IsUpdateComplete()
return self.complete
end
function ContainerManager:GetContainerByName(name)
return self.containersByName[name]
end
|
local PLUGIN = PLUGIN
PLUGIN.name = "Cooking4Kek"
PLUGIN.author = "Kek1ch"
PLUGIN.desc = "Крафт снаряжения и не только."
nut.util.include("sv_plugin.lua")
|
return PlaceObj('ModDef', {
'title', "Depot_OCD",
'description', "Compatible with Cernan Update (Space Race and Green Planet DLC's)\n\nDepot OCD: Giving you the choice of having all Depots as 3hexes long.\n\nEver get triggered by how a Universal Storage Depot is 3 Hexes long and the base plate of Warehouse Depots are 3 Hexes long BUT every other single storage depot is 2 Hexes ~ then this is a mod for you!\n\nCosts;\nFree to build and maintain, just like 2 hex depots.\n\nDue to the extra Hex worth of storage space all 3 hex depots can store a maximum of 330 resources, this is split into a maxium of 11 types at 30 each for a Universal Depot. This is actually proportional to the vanilla storage.\n\nSingle Resource Depots fill up from the right side so the icon is the last thing to be covered by the bottom layer. Universal depots stack from left to right in the same order as is displayed on the infopanel. There is now room and functionality on a Universal Depot for all of LukeH's extra resources and single storage support for that mod is included.\n\nSupport is now included for Seeds single storage and if you own the Green Planet DLC, Seeds should slot into either the middle space of a Universal Storage Depot, or the end space if you also have LukeH's resources.\n\nDepots by default are colourised as per my companion mod (which is still required for the colourisation of 2 hex and Auto/Mechanised Storage Warehouses). I have included a mono- version of the 3 hex depots if that is your preference.\n\nCompatible with saved games. Previously built depots should still function perfectly fine. You can easily cycle through your depots using the InfoBar or the new infopanel button. I would also like to point out that the new 3 Hex Universal Depot should steal the 'U' keybinding assigned in the option menu to become the default, but if it doesn't it is your choice to assign it/ unlink the default game Universal Storage Depot.\n\nI have moved the old Universal Depot into the same sub menu as 2 hex depots and all the 3 hex depots have an entire new sub menu.\n\nBonus feature; The mod standardises the infopanel for all depots, including Waste Rock.\n\nBonus feature; As per a request from DreeseDatalink, Now has MCR options to adjust the amount of storage for all depots (including Waste Rock Dumps, but excluding Black Cube Depots). \nThese options are inspired by another mod and will likely conflict with that mod (or any mod doing similar), because the options adjust the same game values.\nThese options will allow a 2 hex depot to store upto 1,200, a 3 hex depot to store upto 2,200 and Universal Storage Depots to store upto 200 of each resource. Small Waste Rock dumps can store upto 2,100 and Large Waste Rock Dumps can store upto 5,700, I feel these values are in keeping with game balance. \n\nThe amazing MCR can be found here;\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=1542863522\n\nThe inspiration for the Larger Depots MCR options can be found here;\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=1525669914\n\nMy Coloured Depots companion mod can be found here;\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=1575253675\n\nLukeH's extra resources mod can be found here;\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=1742141295 \n\n Special Thanks to;\n Silva for creating the base Blender mesh file for me to texturize and implement\n 'The Surviving Mars Modders Discord' for always being on hand for help and support.\nSirMcKaby, Destroyer of Mods, from the discord group for catching bugs :)\n\nUpdate Notes; If you had built Hydrocarbon Depots prior to v3.2 they might show as a spinning white cube on Game Load, they should be safe to Salvage/remove.\n\nEnjoy!!",
'image', "Thumbnail.jpg",
'last_changes', "v3.5 \nFinally added storages for LukeH's Booze and Meat",
'ignore_files', {
"*.git/*",
"*.svn/*",
"*Preview*",
},
'id', "QSNGAQ2",
'steam_id', "1793460653",
'pops_desktop_uuid', "052756b8-4748-479f-9c54-e3ab62b1df7b",
'pops_any_uuid', "e6c62583-08b5-42ff-a0d9-e90ea8b663da",
'author', "RustyDios",
'version_major', 3,
'version_minor', 5,
'version', 51,
'lua_revision', 233360,
'saved_with_revision', 249143,
'code', {
"Code/AddEntities.lua",
"Code/MCR_Options.lua",
"Code/Script.lua",
},
'saved', 1585205741,
'TagGameplay', true,
'TagBuildings', true,
'TagCosmetics', true,
'TagInterface', true,
'TagOther', true,
}) |
-- Enhanced Raid Frames is a World of Warcraft® user interface addon.
-- Copyright (c) 2017-2021 Britt W. Yazel
-- This code is licensed under the MIT license (see LICENSE for details)
local _, addonTable = ...
local EnhancedRaidFrames = addonTable.EnhancedRaidFrames
local media = LibStub:GetLibrary("LibSharedMedia-3.0")
local unitAuras = {} -- Matrix to keep a list of all auras on all units
EnhancedRaidFrames.iconCache = {}
EnhancedRaidFrames.iconCache["poison"] = 132104
EnhancedRaidFrames.iconCache["disease"] = 132099
EnhancedRaidFrames.iconCache["curse"] = 132095
EnhancedRaidFrames.iconCache["magic"] = 135894
-------------------------------------------------------------------------
-------------------------------------------------------------------------
function EnhancedRaidFrames:SetStockIndicatorVisibility(frame)
if not self.db.profile.showBuffs then
CompactUnitFrame_HideAllBuffs(frame)
end
if not self.db.profile.showDebuffs then
CompactUnitFrame_HideAllDebuffs(frame)
end
if not self.db.profile.showDispellableDebuffs then
CompactUnitFrame_HideAllDispelDebuffs(frame)
end
end
-- Create the FontStrings used for indicators
function EnhancedRaidFrames:CreateIndicators(frame)
frame.ERFIndicators = {}
-- Create indicators
for i = 1, 9 do
--I'm not sure if this is ever the case, but to stop us from creating redundant frames we should try to re-capture them when possible
--On the global table, our frames our named "CompactRaidFrame#" + "ERFIndicator" + index#, i.e. "CompactRaidFrame1ERFIndicator1"
if not _G[frame:GetName().."ERFIndicator"..i] then
--We have to use CompactAuraTemplate to allow for our clicks to be passed through, otherwise our frames won't allow selecting the raid frame behind it
frame.ERFIndicators[i] = CreateFrame("Button", frame:GetName().."ERFIndicator"..i, frame, "ERFIndicatorTemplate")
else
frame.ERFIndicators[i] = _G[frame:GetName().."ERFIndicator"..i]
frame.ERFIndicators[i]:SetParent(frame) --if we capture an old indicator frame, we should reattach it to the current unit frame
end
--create local pointer for readability
local indicatorFrame = frame.ERFIndicators[i]
--mark the position of this particular frame for use later (i.e. 1->9)
indicatorFrame.position = i
--hook OnEnter and OnLeave for showing and hiding ability tooltips
indicatorFrame:SetScript("OnEnter", function() self:Tooltip_OnEnter(indicatorFrame) end)
indicatorFrame:SetScript("OnLeave", function() GameTooltip:Hide() end)
--disable the mouse click on our frames to allow those clicks to get passed straight through to the raid frame behind (switch target, right click, etc)
indicatorFrame:SetMouseClickEnabled(false) --this MUST come after the SetScript lines for OnEnter and OnLeave. SetScript will re-enable mouse clicks when called.
end
--set our initial indicator appearance
self:SetIndicatorAppearance(frame)
end
-- Set the appearance of the Indicator
function EnhancedRaidFrames:SetIndicatorAppearance(frame)
-- Check if the frame has an ERFIndicators table or if we have a frame unit, this is just for safety
if not frame.ERFIndicators or not frame.unit then
return
end
for i = 1, 9 do
--create local pointer for readability
local indicatorFrame = frame.ERFIndicators[i]
--set icon size
indicatorFrame:SetWidth(self.db.profile[i].indicatorSize)
indicatorFrame:SetHeight(self.db.profile[i].indicatorSize)
--------------------------------------
--set indicator frame position
local PAD = 1
local iconVerticalOffset = floor(self.db.profile[i].indicatorVerticalOffset * frame:GetHeight()) --round down
local iconHorizontalOffset = floor(self.db.profile[i].indicatorHorizontalOffset * frame:GetWidth()) --round down
--we probably don't want to overlap the power bar (rage, mana, energy, etc) so we need a compensation factor
local powerBarVertOffset
if self.db.profile.powerBarOffset and frame.powerBar:IsShown() then
powerBarVertOffset = frame.powerBar:GetHeight() + 2 --add 2 to not overlap the powerBar border
else
powerBarVertOffset = 0
end
indicatorFrame:ClearAllPoints()
if i == 1 then
indicatorFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", PAD + iconHorizontalOffset, -PAD + iconVerticalOffset)
elseif i == 2 then
indicatorFrame:SetPoint("TOP", frame, "TOP", 0 + iconHorizontalOffset, -PAD + iconVerticalOffset)
elseif i == 3 then
indicatorFrame:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -PAD + iconHorizontalOffset, -PAD + iconVerticalOffset)
elseif i == 4 then
indicatorFrame:SetPoint("LEFT", frame, "LEFT", PAD + iconHorizontalOffset, 0 + iconVerticalOffset + powerBarVertOffset/2)
elseif i == 5 then
indicatorFrame:SetPoint("CENTER", frame, "CENTER", 0 + iconHorizontalOffset, 0 + iconVerticalOffset + powerBarVertOffset/2)
elseif i == 6 then
indicatorFrame:SetPoint("RIGHT", frame, "RIGHT", -PAD + iconHorizontalOffset, 0 + iconVerticalOffset + powerBarVertOffset/2)
elseif i == 7 then
indicatorFrame:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", PAD + iconHorizontalOffset, PAD + iconVerticalOffset + powerBarVertOffset)
elseif i == 8 then
indicatorFrame:SetPoint("BOTTOM", frame, "BOTTOM", 0 + iconHorizontalOffset, PAD + iconVerticalOffset + powerBarVertOffset)
elseif i == 9 then
indicatorFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -PAD + iconHorizontalOffset, PAD + iconVerticalOffset + powerBarVertOffset)
end
--------------------------------------
--set font size, shape, font, and switch our text object
indicatorFrame.Text:SetText("") --clear previous text
local font = (media and media:Fetch('font', self.db.profile.indicatorFont)) or STANDARD_TEXT_FONT
indicatorFrame.Text:SetFont(font, self.db.profile[i].textSize, "OUTLINE")
--switch the parent for our text frame to keep the text on top of the cooldown animation
if not self.db.profile[i].showCountdownSwipe then
indicatorFrame.Text:SetParent(indicatorFrame)
else
indicatorFrame.Text:SetParent(indicatorFrame.Cooldown)
end
--clear any animations
ActionButton_HideOverlayGlow(indicatorFrame)
CooldownFrame_Clear(indicatorFrame.Cooldown)
indicatorFrame.Icon:SetAlpha(1)
end
end
------------------------------------------------
--------------- Process Indicators -------------
------------------------------------------------
function EnhancedRaidFrames:UpdateIndicators(frame, setAppearance)
--check to see if the bar is even targeting a unit, bail if it isn't
--also, tanks have two bars below their frame that have a frame.unit that ends in "target" and "targettarget".
--Normal raid members have frame.unit that says "Raid1", "Raid5", etc.
--We don't want to put icons over these tiny little target and target of target bars
--Also, in 8.2.5 blizzard unified the nameplate code with the raid frame code. Don't display icons on nameplates
if not frame.unit
or string.find(frame.unit, "target")
or string.find(frame.unit, "nameplate")
or string.find(frame.unit, "pet")
or not CompactRaidFrameContainer:IsShown() then
return
end
self:SetStockIndicatorVisibility(frame)
-- Check if the indicator frame exists, else create it
if not frame.ERFIndicators then
self:CreateIndicators(frame)
end
if setAppearance then
self:SetIndicatorAppearance(frame)
end
-- Update unit auras
self:UpdateUnitAuras(frame.unit)
-- Loop over all 9 indicators and process them individually
for i = 1, 9 do
--create local pointer for readability
local indicatorFrame = frame.ERFIndicators[i]
-- this is the meat of our processing loop
self:ProcessIndicator(indicatorFrame, frame.unit)
end
end
-- process a single indicator and apply visuals
function EnhancedRaidFrames:ProcessIndicator(indicatorFrame, unit)
local i = indicatorFrame.position
local foundAura, icon, count, duration, expirationTime, debuffType, castBy, auraIndex, auraType, _
--reset auraIndex and auraType for tooltip
indicatorFrame.auraIndex = nil
indicatorFrame.auraType = nil
-- if we only are to show the indicator on me, then don't bother if I'm not the unit
if self.db.profile[i].meOnly then
local unitName, unitRealm = UnitName(unit)
if unitName ~= UnitName("player") or unitRealm ~= nil then
return
end
end
--------------------------------------------------------
--- parse each aura and find the information of each ---
--------------------------------------------------------
for _, auraName in pairs(self.auraStrings[i]) do
--if there's no auraName (i.e. the user never specified anything to go in this spot), stop here there's no need to keep going
if not auraName then
break
end
-- query the available information for a given indicator and aura
foundAura, icon, count, duration, expirationTime, debuffType, castBy, auraIndex, auraType = self:QueryAuraInfo(auraName, unit)
-- add spell icon info to cache in case we need it later on
if icon and not self.iconCache[auraName] then
EnhancedRaidFrames.iconCache[auraName] = icon
end
-- when tracking multiple things, this determines "where" we stop in the list
-- if we find the aura, we can stop querying down the list
-- we want to stop only when castBy == "player" if we are tracking "mine only"
if foundAura and (not self.db.profile[i].mineOnly or (self.db.profile[i].mineOnly and castBy == "player")) then
break
end
end
------------------------------------------------------
------- output visuals to the indicator frame --------
------------------------------------------------------
-- if we find the spell and we don't only want to show when it is missing
if foundAura and UnitIsConnected(unit) and not self.db.profile[i].missingOnly and (not self.db.profile[i].mineOnly or (self.db.profile[i].mineOnly and castBy == "player")) then
-- calculate remainingTime and round down, this is how the game seems to do it
local remainingTime = floor(expirationTime - GetTime())
-- set auraIndex and auraType for tooltip
indicatorFrame.auraIndex = auraIndex
indicatorFrame.auraType = auraType
---------------------------------
--- process icon to show
---------------------------------
if icon and self.db.profile[i].showIcon then
indicatorFrame.Icon:SetTexture(icon)
indicatorFrame.Icon:SetAlpha(self.db.profile[i].indicatorAlpha)
else
--set color of custom texture
indicatorFrame.Icon:SetColorTexture(
self.db.profile[i].indicatorColor.r,
self.db.profile[i].indicatorColor.g,
self.db.profile[i].indicatorColor.b,
self.db.profile[i].indicatorColor.a)
-- determine if we should change the background color from the default (player set color)
if self.db.profile[i].colorIndicatorByDebuff and debuffType then -- Color by debuff type
if debuffType == "poison" then
indicatorFrame.Icon:SetColorTexture(unpack(self.GREEN_COLOR))
elseif debuffType == "curse" then
indicatorFrame.Icon:SetColorTexture(unpack(self.PURPLE_COLOR))
elseif debuffType == "disease" then
indicatorFrame.Icon:SetColorTexture(unpack(self.BROWN_COLOR))
elseif debuffType == "magic" then
indicatorFrame.Icon:SetColorTexture(unpack(self.BLUE_COLOR))
end
end
if self.db.profile[i].colorIndicatorByTime then -- Color by remaining time
if remainingTime and self.db.profile[i].colorIndicatorByTime_low ~= 0 and remainingTime <= self.db.profile[i].colorIndicatorByTime_low then
indicatorFrame.Icon:SetColorTexture(unpack(self.YELLOW_COLOR))
elseif remainingTime and self.db.profile[i].colorIndicatorByTime_high ~= 0 and remainingTime <= self.db.profile[i].colorIndicatorByTime_high then
indicatorFrame.Icon:SetColorTexture(unpack(self.RED_COLOR))
end
end
end
---------------------------------
--- process text to show
---------------------------------
if self.db.profile[i].showText ~= "none" then
local formattedTime = ""
local formattedCount = ""
-- determine the formatted time string
if remainingTime and (self.db.profile[i].showText == "stack+countdown" or self.db.profile[i].showText == "countdown") then
if remainingTime > 60 then
formattedTime = string.format("%.0f", remainingTime/60).."m" -- Show minutes without seconds
elseif remainingTime >= 0 then
formattedTime = string.format("%.0f", remainingTime) -- Show seconds without decimals
end
end
-- determine the formatted stack string
if count and count > 0 and (self.db.profile[i].showText == "stack+countdown" or self.db.profile[i].showText == "stack") then
formattedCount = count
end
-- determine the final output string concatenation
if formattedTime ~= "" and formattedCount ~= "" then
indicatorFrame.Text:SetText(formattedCount .. "-" .. formattedTime) --append both values together with a hyphen separating
elseif formattedCount ~= "" then
indicatorFrame.Text:SetText(formattedCount) --show just the count
elseif formattedTime ~= "" then
indicatorFrame.Text:SetText(formattedTime) --show just the time remaining
end
else
indicatorFrame.Text:SetText("")
end
---------------------------------
--- process text color
---------------------------------
--set default textColor to user selected choice
indicatorFrame.Text:SetTextColor(
self.db.profile[i].textColor.r,
self.db.profile[i].textColor.g,
self.db.profile[i].textColor.b,
self.db.profile[i].textColor.a)
if self.db.profile[i].colorTextByDebuff and debuffType then -- Color by debuff type
if debuffType == "curse" then
indicatorFrame.Text:SetTextColor(0.64, 0.19, 0.79, 1)
elseif debuffType == "disease" then
indicatorFrame.Text:SetTextColor(0.78, 0.61, 0.43, 1)
elseif debuffType == "magic" then
indicatorFrame.Text:SetTextColor(0, 0.44, 0.87, 1)
elseif debuffType == "poison" then
indicatorFrame.Text:SetTextColor(0.67, 0.83, 0.45, 1)
end
end
if self.db.profile[i].colorTextByTime then -- Color by remaining time
if remainingTime and self.db.profile[i].colorTextByTime_low ~= 0 and remainingTime <= self.db.profile[i].colorTextByTime_low then
indicatorFrame.Text:SetTextColor(0.77, 0.12, 0.23, 1)
elseif remainingTime and self.db.profile[i].colorTextByTime_high ~= 0 and remainingTime <= self.db.profile[i].colorTextByTime_high then
indicatorFrame.Text:SetTextColor(1, 0.96, 0.41, 1)
end
end
---------------------------------
--- set cooldown animation
---------------------------------
if self.db.profile[i].showCountdownSwipe and expirationTime and duration then
CooldownFrame_Set(indicatorFrame.Cooldown, expirationTime - duration, duration, true, true)
else
CooldownFrame_Clear(indicatorFrame.Cooldown)
end
---------------------------------
--- set glow animation
---------------------------------
if self.db.profile[i].indicatorGlow and (self.db.profile[i].glowRemainingSecs == 0 or self.db.profile[i].glowRemainingSecs >= remainingTime) then
ActionButton_ShowOverlayGlow(indicatorFrame)
else
ActionButton_HideOverlayGlow(indicatorFrame)
end
indicatorFrame:Show() --show the frame
elseif not foundAura and self.db.profile[i].missingOnly then --deal with "show only if missing"
local auraName = self.auraStrings[i][1] --show the icon for the first auraString position
--check our iconCache for the auraName. Note the icon cache is pre-populated with generic "poison", "curse", "disease", and "magic" debuff icons
if not self.iconCache[auraName] then
_,_,icon = GetSpellInfo(auraName)
if not icon then
icon = "Interface\\Icons\\INV_Misc_QuestionMark"
end
else
icon = self.iconCache[auraName]
end
if self.db.profile[i].showIcon then
indicatorFrame.Icon:SetTexture(icon)
indicatorFrame.Icon:SetAlpha(self.db.profile[i].indicatorAlpha)
indicatorFrame.Text:SetText("")
else
--set color of custom texture
indicatorFrame.Icon:SetColorTexture(
self.db.profile[i].indicatorColor.r,
self.db.profile[i].indicatorColor.g,
self.db.profile[i].indicatorColor.b,
self.db.profile[i].indicatorColor.a)
indicatorFrame.Text:SetText("")
end
indicatorFrame:Show() --show the frame
else
indicatorFrame:Hide() --hide the frame
--if no aura is found and we're not showing missing, clear animations and hide the frame
CooldownFrame_Clear(indicatorFrame.Cooldown)
ActionButton_HideOverlayGlow(indicatorFrame)
end
end
--process the text and icon for an indicator and return these values
--this function returns foundAura, icon, count, duration, expirationTime, debuffType, castBy, auraIndex, auraType
function EnhancedRaidFrames:QueryAuraInfo(auraName, unit)
-- Check if the aura exist on the unit
for _,v in pairs(unitAuras[unit]) do --loop through list of auras
if (tonumber(auraName) and v.spellID == tonumber(auraName)) or v.auraName == auraName or (v.auraType == "debuff" and v.debuffType == auraName) then
return true, v.icon, v.count, v.duration, v.expirationTime, v.debuffType, v.castBy, v.auraIndex, v.auraType
end
end
-- Check if we want to show pvp flag
if auraName:upper() == "PVP" then
if UnitIsPVP(unit) then
local factionGroup = UnitFactionGroup(unit)
if factionGroup then
return true, "Interface\\GroupFrame\\UI-Group-PVP-"..factionGroup, 0, 0, 0, "", "player"
end
end
end
-- Check if we want to show ToT flag
if auraName:upper() == "TOT" then
if UnitIsUnit(unit, "targettarget") then
return true, "Interface\\Icons\\Ability_Hunter_SniperShot", 0, 0, 0, "", "player"
end
end
return false
end
------------------------------------------------
---------- Update Auras for all units ----------
------------------------------------------------
function EnhancedRaidFrames:UpdateUnitAuras(unit)
-- Create or clear out the tables for the unit
unitAuras[unit] = {}
-- Get all unit buffs
local i = 1
while (true) do
local auraName, icon, count, duration, expirationTime, castBy, spellID
if not self.isWoWClassic then
auraName, icon, count, _, duration, expirationTime, castBy, _, _, spellID = UnitAura(unit, i, "HELPFUL")
else
auraName, icon, count, _, duration, expirationTime, castBy, _, _, spellID = self.UnitAuraWrapper(unit, i, "HELPFUL") --for wow classic. This is the LibClassicDurations wrapper
end
if not spellID then --break the loop once we have no more buffs
break
end
--it's important to use the 4th argument in string.find to turn of pattern matching, otherwise things with parentheses in them will fail to be found
if auraName and self.allAuras:find(" "..auraName:lower().." ", nil, true) or self.allAuras:find(" "..spellID.." ", nil, true) then -- Only add the spell if we're watching for it
local auraTable = {}
auraTable.auraType = "buff"
auraTable.auraIndex = i
auraTable.auraName = auraName:lower()
auraTable.icon = icon
auraTable.count = count
auraTable.duration = duration
auraTable.expirationTime = expirationTime
auraTable.castBy = castBy
auraTable.spellID = spellID
table.insert(unitAuras[unit], auraTable)
end
i = i + 1
end
-- Get all unit debuffs
i = 1
while (true) do
local auraName, icon, count, duration, expirationTime, castBy, spellID, debuffType
if not self.isWoWClassic then
auraName, icon, count, debuffType, duration, expirationTime, castBy, _, _, spellID = UnitAura(unit, i, "HARMFUL")
else
auraName, icon, count, debuffType, duration, expirationTime, castBy, _, _, spellID = self.UnitAuraWrapper(unit, i, "HARMFUL") --for wow classic. This is the LibClassicDurations wrapper
end
if not spellID then --break the loop once we have no more buffs
break
end
--it's important to use the 4th argument in string.find to turn off pattern matching, otherwise things with parentheses in them will fail to be found
if auraName and self.allAuras:find(" "..auraName:lower().." ", nil, true) or self.allAuras:find(" "..spellID.." ", nil, true) or (debuffType and self.allAuras:find(" "..debuffType:lower().." ", nil, true)) then -- Only add the spell if we're watching for it
local auraTable = {}
auraTable.auraType = "debuff"
auraTable.auraIndex = i
auraTable.auraName = auraName:lower()
auraTable.icon = icon
auraTable.count = count
if debuffType then
auraTable.debuffType = debuffType:lower()
end
auraTable.duration = duration
auraTable.expirationTime = expirationTime
auraTable.castBy = castBy
auraTable.spellID = spellID
table.insert(unitAuras[unit], auraTable)
end
i = i + 1
end
end
------------------------------------------------
----------------- Tooltip Code -----------------
------------------------------------------------
function EnhancedRaidFrames:Tooltip_OnEnter(indicatorFrame)
local i = indicatorFrame.position
if not self.db.profile[i].showTooltip then --don't show tooltips unless we have the option set for this position
return
end
local frame = indicatorFrame:GetParent() --this is the parent raid frame that holds all the indicatorFrames
-- Set the tooltip
if indicatorFrame.auraIndex and indicatorFrame.Icon:GetTexture() then -- -1 is the pvp icon, no tooltip for that
-- Set the buff/debuff as tooltip and anchor to the cursor
GameTooltip:SetOwner(UIParent, self.db.profile[i].tooltipLocation)
if indicatorFrame.auraType == "buff" then
GameTooltip:SetUnitAura(frame.unit, indicatorFrame.auraIndex, "HELPFUL")
else
GameTooltip:SetUnitAura(frame.unit, indicatorFrame.auraIndex, "HARMFUL")
end
else
--causes the tooltip to reset to the "default" tooltip which is usually information about the character
if frame then
UnitFrame_UpdateTooltip(frame)
end
end
GameTooltip:Show()
end |
--- Pseudo-random sort.
local A, L = unpack(select(2, ...))
local P = A.sortModes
local M = P:NewModule("random", "AceEvent-3.0")
P.random = M
local format, random, sort, strbyte, strlen, wipe = format, random, sort, strbyte, strlen, wipe
local fmod = math.fmod
local salt = ""
local hashCache = {}
local function hash(text)
local v = hashCache[text]
if v then
return v
end
-- Credit to Mikk for the original hashing function this code is adapted from:
-- http://wow.gamepedia.com/StringHash
local src = salt..text
local len = strlen(src)
v = 1
for i = 1, len, 3 do
v = fmod(v*8161, 4294967279) + -- 2^32 - 17: Prime!
(strbyte(src,i)*16776193) +
((strbyte(src,i+1) or (len-i+256))*8372226) +
((strbyte(src,i+2) or (len-i+256))*3932164)
end
v = fmod(v, 4294967291) -- 2^32 - 5: Prime (and different from the prime in the loop)
hashCache[text] = v
return v
end
function M:OnEnable()
A.sortModes:Register({
key = "random",
name = L["sorter.mode.random"],
desc = function(t)
t:AddLine(format("%s:|n%s.", L["tooltip.right.fixGroups"], L["sorter.mode.random"]), 1,1,0, true)
t:AddLine(" ")
t:AddLine(L["sorter.print.notUseful"], 1,1,1, true)
end,
getDefaultCompareFunc = true,
onBeforeStart = function()
salt = random()
wipe(hashCache)
end,
onSort = function(sortMode, keys, players)
sort(keys, function(a, b)
return hash(a) < hash(b)
end)
end,
})
end
|
return (function(self, name, value)
api.log(4, 'setting attribute %s on %s to %s', name, tostring(self:GetName()), tostring(value))
u(self).attributes[name] = value
api.RunScript(self, 'OnAttributeChanged', name, value)
end)(...)
|
exports['Scoreboard']:scoreboardAddColumn ( "Money" );
for i, v in ipairs ( getElementsByType ( "player") ) do
if ( not getElementData ( v, "Money")) then
setElementData ( v, "Money", "$0" )
end
end
addEventHandler ( "onPlayerJoin", root, function ( )
setElementData ( source, "Money", "$0" )
end )
addEventHandler ( "onPlayerLogin", root, function ( )
setTimer ( function ( p )
if ( isElement ( p )) then
setElementData ( p, "Money", "$"..convertNumber ( getPlayerMoney ( p ) ) )
end
end, 1000, 1, source )
end )
setTimer ( function ( )
for i, v in ipairs ( getElementsByType ( "player" ) ) do
setElementData ( v, "Money", "$"..convertNumber ( getPlayerMoney ( v ) ) )
end
end, 5000, 0 )
function convertNumber ( number )
local formatted = number
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if ( k==0 ) then
break
end
end
return formatted
end |
--[[
File-Author: Pyrr
File-Hash: 7d854c80b8da104d80127c2e9eec1db83cd3fa31
File-Date: 2018-03-30T22:15:20Z
]]
local lib,name,path = ...
------------------------------------------------------ lib.color ------------------------------------------------------
local me = {
exports = {"GetColorByName", "GetColorByItemRarity","RGBtoHEX","RGBAtoHEX","HEXtoRGBA"},
}
me.colors = {
red = {{1,0,0}, {0.7,0.7,1}},
yellow = {{1,1,0},},
orange = {{1,0.5,0}, {1,1,1}},
green = {{0,1,0}, {0.3,0.3,1}},
cyan = {{0,1,1}},
blue = {{0,0,1}},
lightblue = {{0.4,0.4,1}},
magenta = {{1,0,1},{1,1,1}},
white = {{1,1,1}},
lightgray = {{0.75,0.75,0.75}},
gray = {{0.5,0.5,0.5}},
darkgray = {{0.25,0.25,0.25}},
black = {{0,0,0}},
-- rarity colors:
[0] = {{GetItemQualityColor(0)}},
[1] = {{GetItemQualityColor(1)}},
[2] = {{GetItemQualityColor(2)}},
[3] = {{GetItemQualityColor(3)}},
[4] = {{GetItemQualityColor(4)}},
[5] = {{GetItemQualityColor(5)}},
[6] = {{GetItemQualityColor(6)}},
[7] = {{GetItemQualityColor(7)}},
[8] = {{GetItemQualityColor(8)}},
[9] = {{GetItemQualityColor(9)}},
[10] = {{1, 0, 0}},--physical skill
[11] = {{0, 1, 0}}, --magical skill
[12] = {{0.1, 0.68, 0.21}}, --passive skill
[13] = {{1, 0, 0}},--red stat
[14] = {{0, 1, 0}},--green stat
[15] = {{1, 1, 0}},--yellow stat
[16] = {{0.94, 0.38, 0.05}},-- orange stat
[17] = {{0.94, 0.08, 0.88}},-- purple stat
}
me._Init = function(val)
if val then return end
me.Settings = me:GetTableRoot().Settings
end
me.ToggleColorblind = function()
me.Settings.Colorblind = not me.Settings.Colorblind
printf("Colorblind Mode: %s", me.Settings.Colorblind and "Enabled" or "Disabled")
me.SendEvent("PYLIB_TOGGLE_COLORBLIND", me.Settings.Colorblind)
end
me.GetColorByName = function(name)
name = name or "";
name = me.colors[name] or me.colors[string.lower(name)]
if not name then return {1,1,1} end
if me.Settings.Colorblind then
return name[2] or name[1] or {1,1,1}
end
return name[1] or {1,1,1}
end
me.GetColorByItemRarity = function(num)
return unpack(me.GetColorByName(num or 0))
end
me.GetColorListByItemRarity = function(num)
return me.GetColorByName(num or 0)
end
me.RGBtoHEX = function(r,g,b)
r=math.floor(math.max(math.min(type(r)=="number" and r or 0,1),0)*255+0.5)
g=math.floor(math.max(math.min(type(g)=="number" and g or 0,1),0)*255+0.5)
b=math.floor(math.max(math.min(type(b)=="number" and b or 0,1),0)*255+0.5)
return string.format("%02x%02x%02x",r,g,b)
end
me.RGBAtoHEX = function(r,g,b,a)
local rgb = me.RGBtoHEX(r,g,b)
a=math.floor(math.max(math.min(type(a)=="number" and a or 1,1),0)*255+0.5)
return string.format("%02x%s",a,rgb)
end
me.HEXtoRGBA = function(str)
local a,r,g,b = string.match(str,"^(%x%x)(%x%x)(%x%x)(%x%x)$")
if not a then
r,g,b = string.match(str,"^(%x%x)(%x%x)(%x%x)$")
a = 1
end
if not r then return 0,0,0,0 end
return tonumber(r,16)/255,tonumber(g,16)/255,tonumber(b,16)/255,tonumber(a,16)/255
end
lib.CreateTable(me, name,path, lib)
|
local gears = require("gears")
local naughty = require("naughty")
require("socket")
local socket_unix = require("socket.unix")
local notify = {}
function notify.watch(args)
args = args or {}
local socket_name = args.socket_filename
if not socket_name then
local xdg_dir = os.getenv("XDG_RUNTIME_DIR")
socket_name = xdg_dir .. "/yubikey-touch-detector.socket"
end
local socket = socket_unix()
local connected = socket:connect(socket_name)
if not connected then
existing_notify = naughty.notify({
title = "Yubikey notify initialization error",
preset = naughty.config.presets.critical,
text = "Couldn't connect to yubikey-touch-detector socket!",
})
return
end
socket:settimeout(0)
existing_notify = nil
return gears.timer.start_new(
args.timeout or 0.5,
function()
-- We always get 5 bytes, e.g. GPG_1, SSH_0
data = socket:receive(5)
if data then
title = args.title or "Yubikey waiting on touch..."
get_next_word = string.gmatch(data, "(%w+)")
text = get_next_word()
switch = get_next_word()
if switch == "1" then
existing_notify = naughty.notify({
title = title,
icon = args.icon,
width = args.width,
height = args.height,
position = "top_middle",
text = text,
timeout = 0
})
else
if existing_notify then
naughty.destroy(existing_notify, naughty.notification_closed_reason.expired)
existing_notify = nil
else
naughty.replace_text(existing_notify, title, text)
end
end
end
return true
end
)
end
return notify
|
-- Petit WEB IDE tout simple autonome
-- ATTENTION: tourne sur le port 88 !
print("\n _web_ide2.lua zf190227.1739 \n")
--[[
XChip's NodeMCU IDE
Create, Edit and run NodeMCU files using your webbrowser.
Examples:
http://<mcu_ip>/ will list all the files in the MCU
http://<mcu_ip>/newfile.lua displays the file on your browser
http://<mcu_ip>/newfile.lua?edit allows to creates or edits the specified script in your browser
http://<mcu_ip>/newfile.lua?run it will run the specified script and will show the returned value
]]--
srv=net.createServer(net.TCP)
srv:listen(88,function(conn)
local rnrn=0
local Status = 0
local DataToGet = 0
local method=""
local url=""
local vars=""
conn:on("receive",function(conn,payload)
if Status==0 then
_, _, method, url, vars = string.find(payload, "([A-Z]+) /([^?]*)%??(.*) HTTP")
print(method, url, vars)
end
if method=="POST" then
if Status==0 then
--print("status", Status)
_,_,DataToGet, payload = string.find(payload, "Content%-Length: (%d+)(.+)")
if DataToGet~=nil then
DataToGet = tonumber(DataToGet)
--print(DataToGet)
rnrn=1
Status = 1
else
print("bad length")
end
end
-- find /r/n/r/n
if Status==1 then
--print("status", Status)
local payloadlen = string.len(payload)
local mark = "\r\n\r\n"
local i
for i=1, payloadlen do
if string.byte(mark, rnrn) == string.byte(payload, i) then
rnrn=rnrn+1
if rnrn==5 then
payload = string.sub(payload, i+1,payloadlen)
file.open(url, "w")
file.close()
Status=2
break
end
else
rnrn=1
end
end
if Status==1 then
return
end
end
if Status==2 then
--print("status", Status)
if payload~=nil then
DataToGet=DataToGet-string.len(payload)
--print("DataToGet:", DataToGet, "payload len:", string.len(payload))
file.open(url, "a+")
file.write(payload)
file.close()
else
conn:send("HTTP/1.1 200 OK\r\n\r\nERROR")
Status=0
end
if DataToGet==0 then
conn:send("HTTP/1.1 200 OK\r\n\r\nOK")
Status=0
end
end
return
end
DataToGet = -1
if url == "favicon.ico" then
conn:send("HTTP/1.1 404 file not found")
return
end
conn:send("HTTP/1.1 200 OK\r\n\r\n")
-- it wants a file in particular
if url~="" and vars=="" then
DataToGet = 0
return
end
conn:send("<html><body><h1>NodeMCU IDE</h1>".."Connected IP: "..wifi.sta.getip().."<br><br>")
if vars=="edit" then
conn:send("<script>function tag(c){document.getElementsByTagName('w')[0].innerHTML=c};\n")
conn:send("var x=new XMLHttpRequest()\nx.onreadystatechange=function(){if(x.readyState==4) document.getElementsByName('t')[0].value = x.responseText; };\nx.open('GET',location.pathname,true)\nx.send()</script>")
conn:send("<h2><a href='/'>Back to file list</a>\n")
conn:send("<br><br><button onclick=\"tag('Saving');x.open('POST',location.pathname,true);\nx.onreadystatechange=function(){if(x.readyState==4) tag(x.responseText);};\nx.send(new Blob([document.getElementsByName('t')[0].value],{type:'text/plain'}));\">Save</button><a href='?run'>run</a><w></w>")
conn:send("</h2><br><textarea name=t cols=110 rows=50></textarea></br>")
end
if vars=="run" then
conn:send("<verbatim>")
local st, result=pcall(dofile, url)
conn:send(tostring(result))
conn:send("</verbatim>")
end
if url=="" then
local l = file.list();
for k,v in pairs(l) do
conn:send("<a href='"..k.."?edit'>"..k.."</a>, size:"..v.."<br>")
end
end
conn:send("</body></html>")
end)
conn:on("sent",function(conn)
if DataToGet>=0 and method=="GET" then
if file.open(url, "r") then
file.seek("set", DataToGet)
local line=file.read(512)
file.close()
if line then
conn:send(line)
DataToGet = DataToGet + 512
if (string.len(line)==512) then
return
end
end
end
end
conn:close()
end)
end)
print("listening, free:", node.heap())
|
-- Copyright 2015 Boundary
-- @brief convenience variables and functions for Lua scripts
-- @file boundary.lua
local fs = require('fs')
local json = require('json')
local boundary = {param = nil}
-- import param.json data into a Lua table (boundary.param)
local json_blob
if (pcall(function () json_blob = fs.readFileSync("param.json") end)) then
pcall(function () boundary.param = json.parse(json_blob) end)
end
return boundary
|
local stats = require "util.statistics".new();
local config = require "core.configmanager";
local log = require "util.logger".init("stats");
local timer = require "util.timer";
local fire_event = prosody.events.fire_event;
local stats_config = config.get("*", "statistics_interval");
local stats_interval = tonumber(stats_config);
if stats_config and not stats_interval then
log("error", "Invalid 'statistics_interval' setting, statistics will be disabled");
end
local measure, collect;
local latest_stats = {};
local changed_stats = {};
local stats_extra = {};
if stats_interval then
log("debug", "Statistics collection is enabled every %d seconds", stats_interval);
function measure(type, name)
local f = assert(stats[type], "unknown stat type: "..type);
return f(name);
end
local mark_collection_start = measure("times", "stats.collection");
local mark_processing_start = measure("times", "stats.processing");
function collect()
local mark_collection_done = mark_collection_start();
changed_stats, stats_extra = {}, {};
for stat_name, getter in pairs(stats.get_stats()) do
local type, value, extra = getter();
local old_value = latest_stats[stat_name];
latest_stats[stat_name] = value;
if value ~= old_value then
changed_stats[stat_name] = value;
end
if extra then
stats_extra[stat_name] = extra;
end
end
mark_collection_done();
local mark_processing_done = mark_processing_start();
fire_event("stats-updated", { stats = latest_stats, changed_stats = changed_stats, stats_extra = stats_extra });
mark_processing_done();
return stats_interval;
end
timer.add_task(stats_interval, collect);
prosody.events.add_handler("server-started", function () collect() end, -1);
else
log("debug", "Statistics collection is disabled");
-- nop
function measure()
return measure;
end
function collect()
end
end
return {
measure = measure;
collect = collect;
get_stats = function ()
return latest_stats, changed_stats, stats_extra;
end;
};
|
local ui = {
logo_string = '<img src="data:image/png;base64,'
..'iVBORw0KGgoAAAANSUhEUgAAARIAAAA/CAYAAAAsckd/AAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpSIVwXYQcQhSnayIijhqFYpQIdQKrTqYXPoFTRqSFBdHwbXg4Mdi1cHFWVcHV0EQ/ABxc3NSdJES/5cUWsR6cNyPd/ced+8AoVZimtUxDmi6bSbjMTGdWRUDrxDQhxDGMCQzy5iTpATajq97+Ph6F+VZ7c/9OXrUrMUAn0g8ywzTJt4gnt60Dc77xGFWkFXic+JRky5I/Mh1xeM3znmXBZ4ZNlPJeeIwsZhvYaWFWcHUiKeII6qmU76Q9ljlvMVZK1VY4578hcGsvrLMdZqDiGMRS5AgQkEFRZRgI0qrToqFJO3H2vgHXL9ELoVcRTByLKAMDbLrB/+D391auckJLykYAzpfHOdjGAjsAvWq43wfO079BPA/A1d601+uATOfpFebWuQI6N0GLq6bmrIHXO4A/U+GbMqu5Kcp5HLA+xl9UwYI3QLda15vjX2cPgAp6ipxAxwcAiN5yl5v8+6u1t7+PdPo7weV5XK14oVS9QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+UCEhQBI6rep3oAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAgAElEQVR42u1deXhU1dn/nZnJShICYV/DjhgXlNUNBRdMqpWixN3iRtVWcW1Fv7r1009xQ1u1tVZEK0Qrbk0EBFEQwQUFZJeQELJAQiDbJDOTzPy+P+6ZMgx3OXdmYhXmfR6f4Nzznvue5b7nPe8qEAMgOQjAWQDOAHAcgCz5XwKAOgAVANYDWAngbSFEA+IQhzjEgaSL5DSSn9IeuEk+SjI5Potx+C/uXyfJ80j+jeQ3JGtJtsq/n5OcRbJ7fKbadxFOJvkto4N1JDvHZzMO/4X9O5HkFoU92kjyhviMtc8i3EayzWDim0g+TnIMyQySCST7kLyGZIlO+9UkXfFZjcOPuH/vieDQuyc+c7FdhHtNJruS5DAT3N4kG3Twrrfx/gSSg6VIehPJJ0kulNLNh/EVUprDdJInkJxC8i6SL5JcQrKY5BVH+Njvi1B6biN5Unz3xGYR8iwm+xyFPh7WwftYAe+XUqJpM3n/4/FVMp3DV0nutVjD4Ufw+M8i6Y/iKv5qfBdFvwidpMRhBNsU+zlHB3ePAt4LCgs9Nb5ShvPnlEpuM9hPUhyh408mWaawh1aTnEAyjeSJJL8MebY5vpOiX4gHLRZgnmI/J+vgtijgrVXYBH3iK2U4fycozN+iI3j8v1MY/0qSSWF4x9k58I5mcCi2u8ri+X7FfrJ1fnNbbIIUAMdb9FslhCiPL6chjFVo8+URPP4ZFs/9AKYLIbxhv+8O+XdzfBsZg6XFhGRfAAMtmqUovu8Cnd9+sMA5SYHOL+NLGTUjWXOESiPDARxr0axQCLFD5/fUkL31fXwbRcFIAAxRaDNUYUF7ArhY59HiGHwEX8WXMi6RGMC5Cm2K9H4UQlQCGBffPrG52qh4oJ5CMtOEiTgA/BVAh7BHjQD+Fv8I2vVETgNwjEWzH4QQ+4/QKThFoc2K+E5pf0ZSo9AmEcCtJs9f0bnWBADMkFw/GkYSAPBNfCkNYbTCOq85gsdvJVHUA9ga3ybtf6L1ULSze0jmGN1TSRZJE2S9dIA6Q+Hd3RXeuym+SqZz+AeFObz5CB17N4WxL43vkh9BRyKE2ENyA6wtJ0kA5pM8NTy6VwixFUBu/G7/k9WPrDmKx/6z2z/S36cnNCPIIJ2/k4QQG39SjETCAgVGAgA5AN4nOVnHlNZeGyGuaDWHMRbPWwBsOErH/rPaP9JXajGAATC3lHb4qQ6gI8l9NtyJF5NMjcF7lyq8a6Rsm0jyMpKvk9xBskXG9mwgOYfkMTGai24kbyT5IcnN0iPUR7Ka5DKSF8l2o1ScoNqJhmnBjdeONCSRnBoShr9P0tAivaAXyQDPdIt+tirQ2D2k/QCSs0luku+qJ1lI8gSdvhez/eF1g3E5ZRCrGTRIQ4TqnN+uSNPEKPd4KslLSf5DRvnXyrVtJllO8t8y1i01ks5vsTnBn5PsFMVgHHKTmEGzzIsykWSpQuDVw1HQ05XkX2TOCiv4HcnrFdo92Y403C8/dCuYbZOGRJIzbRwse0ieYnJABSzwi2XbZJKPmYy9geSIUPFfMtj2ht8ajE3Fm3iZzblfo0jThRHu8RQZmFun+J5dJE+0fS8j+bHNSd5CckCEgzpWkVldo/hhBWFWBLT8ysbkBpM3zVVod3E70uCV0kIsaRgvo4Ttwj69JEEkz1bAfYPkMYqSy6KQvocqtH/JYrwqOUtGG+DeqID7qI2576fAdINweQR7fBLJ3RGsbQXJjnZf1tMieE8PqvTEToV3XavQ99YIIjrdJLvaoONPEZ5UnljFB0VBQ3MMaZgumZMRfCUZTQcDeu/T6XOWAn3/InnARrh/uuz7SoX215mMN0Phw/WQTDTAf0Xh/b+0sQ/vtLHuM2x+a7daHMar5FU9jeRzOs9viURSOEnh7hcOdUbircl7/tqO4uhVijT8r0JfP8j7ZJac6DsUmVt5O9HQmeQMRSlNlYabFaJmU0Lad9ZpU6jT73s2rkc3yYPsDIu2Q2Xfzyn0e7zJmCeqRAub4G9UwO9h43tYb2N/32mjXytmviI0mJHkQJ02/4xUX5BrkRvEKEz9GBvvWNeOjOTpGHw8JLlceo5Gchr9q51peDlGNEyxYIyVJLvo4IXjfK3TRkW6/Sz8WmSSV8UfFLPDUgAYSaZOk3Gr+N88a4CbrnCY7LJ5eAdB5XrzkGK/11gdNAxLhyoltcNyCjkiYSRCiCIAv7WJ1gnAIirkaZXa4BzFfjcCmChNXqMA7FDAybJ4/wgAT1n0UQrgV0KIJp1n66L1X4gBDetjQEM2gHkw94z9jRBiXxheFx0cT1ibvtIXwgw+AXCuEGJv2O9GnswfCyHq5XXD6jr9rRDCb/J8dBTzp+JNbMd/ZXrIvz9VaJ+hooOEFrZiBjN0Qie66bTzRMRIJDN5SWGjh0M/AC8qtBsFwKnQbhuA04UQy4UQzUKItQDuV8BrM7MWyY8n2QL/YiHEgSg24Zp2puHkKGkQAP4BIM0Ef5kQ4gOd3/WibUsi8PF4y8AfaaHOb7U4GKZxAjQHyWj8R8ZEwUhi5v8kmeJlIQeUCgPKtOjTBWCuxRwtEkIUqq5txIxEwj0APrCJM00hm9lYxb5uFELURSANHDB5doXCR/iKZFpGME6BkX3zE6DBDP9yaLWKzOB/DH7XUyKujOBDNZqj1wHMB9AEYB+ANwGMFkJst7F/vjb50HoAsFJC7xNC7Ixi/6pKJFNCJOi3oZb7J9NK0pCHdSRr+yud31YhWpBa+u9s6ig2mTniSE29FRQYieORxpZQSy5domAJ6WVCe5bC+9ea4MeChk4Kd+lvTfCdJLdZ4H9lgNtRx3+jmWRWWLvlCubrxAj35DyFNRhkgn+hAv6/TfCrFKxLqYpjWROC00fRmvmZSX/J0mRrG59aAvdmHUNKWrQSCYQQbmiRvdU20EZAPzeJHY5udEXqooBrFOh3CfSzuB1yGlpELKvkrzCLbYkFDWMBiChoyId1jhkjH4w/Sn1YKPxFCFEbdnWzkrg2CCF8EW5LK2lnvxCiuD30IyT7AbCyxnwvhGhWYCLjQ76FQpkFcJ8CbWZ6yGsB9LLA/4vB7/+Hw13znzLQ0UUsmUy1KZV8bNBPLwXcUhokKlbwH2gzctsm+YXCu8dZzMMj0ZifY0TDQwp9XG2Cb1U90Ued/DMkL9KRhLaHmoZluxwF+l6McB+qeMsusuhDxbX+XAPcS6J1hAvpqyAE5/wgc1FxEjPp08oaWs+w3LUST89Tex3JBKtBjCb5LMnvZeeN8kryAskhUVxJgtBKsoNOH1MUcF83oXt2JNcKksNUHOAUFl8lPmhoO9OwJAoaBil8iB8ZHCQtYe2aSI7Vaasinl8XISM5R6Hvhy36qLXAD9AgkRe1WktWMF1hHP1CfIG2BA9OuT6WzpAGfZ6kgDtPB2+6jl9SHUPShjgMJIJ/S63ybdDMsBlSez8CwE0A1gU5pI6CJqC45i5o+Vhjrag61QLXKEhNpZxFocXiOxTE4v0hSsH2oEEoiPYHYJwr9yKFa9GiMAngeQBvhVmZ3ADyhBBfRmgRiTRZlUrfZorWwRZXAwDYrqPkj7Wi9X4cjM5/UghB+W+VbPZJer5FUnFrBR+GzEWmlJ7+gUMzBdQBOMcwVQHJkdKLUNXBTE+8fduGVPJrHfzlCnijDOhPsnDjNowtUXBgIsnJFh+xisheZIIfCxpUYpQ+ilKiOlP+N8fg9P6B5BiTd1jVjW5mhKVcSb6vQH93E/zLFPBfM8B10bp+kGXEL7Vqkq0hDn+JYc8bFWjM1un3Gwscv4xROl3eRvTW9nszj+CgRraC9uDaCK8mQbgr/ERXmKQWo3uZnADbm0hanqxcyi017SRvUHj/H02sX7GgQSXq+AETi1FLFB7DPpLP611ZQ96RojDO1VHo6qwsJmUW+M9EYfUbqYC7TGEMb4a0n6nzfLvCe0aH4ajEDll9d4/r6U8QJq7MUdDmlkFzZFkqLR964t0SAF5YOwRBRwOcA3MHKEDzSGyN8FqzRcdLMigOW52AOxQ07dFYbH5MGoxE6+Ogluw7HBrkvnhSCLHboq1KeZFvImQiKhaTr2NwNYrGEc3Km/h4AJeGXGP0vE/3wLq6Q3hg6iiFK6vuVRzA3wE8I4TYY6anALUCyVb38/8D8JAQwmPWSAjhplbecKQCkc0RLISZ2fI0C9xPDX5XccdXSV033mqvw9ij8cekwWgzq6yZH1rhqGJomdWKAHxmwtx/avqRr0w+YpfCHHhgnFEuKkZCshuAF0I++L8JIVoMGAlsMhKVtW0DsEuu7Tq5tp9bhBIcIpFcatHu90KIJ2ws6F7FdnWxWgipZDwlQkYySOG9JRYnSUcAVkW4t5ko6X4sGrabuNUPVqDhUSHEHxE5tCcjicqjVTJzq2JvZhJxNPt3mDQEhDKAO0h+IoQIdxBT8dlKj2Bt7xJCzIlk4oNKn8kWEsBsm/3WKLbbEUOJ5Fgc7ggVDkYWm14K7z2gsImjcQI7PkY0RFN6YrwCDfVR6C/SFQ6tJgBb2olJ0YJJnRwFI+iswMTL9K4HJJOhWePCpYg0AHcZzJEVhOupLojgYLfNSLJN2vwtxPSkCir37ABCyiBKc9UIC5w9QggjZZmVNFIhhKiKgpG4LZ5PjvJ+fNZPgIYJCvi+KJjItwpNvxNCBCLo3wF9d4JwibAhSmZudDW6XOEgMcK92kQibVFQCehBaH6YqQB628GxzUgkNzRL0BtJzVMVN/VvwkKUoy3kZBU2blZj+FQFetNNNnEytEA7K9hmgK+a27Y9aeisSENyBB95qrxvq4jXkV5rjoW1ot5K0TpC4T1GrvXXRzr30MIijOANnd9UIuN9MmbqQWjBfirQPVJG4lLgog02N40AoJIQ9vVY3S8lWCVNaozyAzLbZPdCP09DOBhlJJv9I9JgZFVRTUTdy+Z+yATwPqwV4T+GfuSrGHxItTpjvFbhIAM0q6cenK3TLgGapUQvul4ls1oygM9hr3bxKYprOhmAEEJ8FP7ALFv72TY3jkoswF6SGWF476o4Qpm81yq13VYdHBe11Pqq6SI76vRxuY1sceN18C+2YctXoiEQCHD3rt2WcTp3jLl91h2jb3vBJg1f2NgLx/NgAmVVH4ahkXARqiW6HmvRR4lCHxPCcAZRPVv9vXoHWVibuQpj3WJjvTwy/qxAoa2fBsms5XuHkVwg2/bXa7DSpPNnbC6oimfrpTp4lQrOWGkm71Vx0nmYWhnQFGq5P1fYdMoplGkKEkgep5hSMTwt4gjpgdtPBtf5Yk2D1+vjny5/hBXllYY0rFy5Kv36vHu2lBSXvGCThgAt8u9K56dHeWgC7N+RrFFglCJCRmIVjOYzcqaycRiRWiWFnjI04AraS4ZeIT2CU6X7+TRqNZhC4X0LGifZeN/O4MGhmDqSco2ulgwuVTKPa6iV3A0eVhuMiLvHpOMmPXdbg36mqXwIOnh9FfDWW7x7Jf+7sDRK/PdiScOeqr187onX2NyspY/w+XxscrtZuquMe6uruXHzdhYWfhaO/67ie+pJ3iVduRPlhusno39fkm7goTCL+kmDw+GTCJlIqoJU+I1CP0uimPt3aT+PsR54ZbyPHn29aF2/6T+BraFSP8lxMdzr040msLNFxOMGkr0tFuFKhTiX76lTCkJRtP6rxftnRzEx/1CM8TGCFfIU9kSIv0p+kDGlYfOWYs5972O+ufpbvrLkO65YXcxVa4o5d9lG3vDeF/x83SEH8Eop5SyP4Ybzkbxero9KDMsTETISldCIFxT6eSjCcVZSS2i1IUbzVkwtuVKG3BdDqVUnqFbALSX5C4PxfRsD2rbQLOGUwsdcS/IBGU+QLgfYV26QT1QkCupkG7fBBK612AQ5EcYSrKGWNerUCE+UTZRlBWgvjcJ/dDfBeYk1DS0tLbzizY+4ZHUxWxrd9FQ1snnHXroPNHDt1+t42fPvsLpmX3BzdAk5uXwx2HBloTotxRiWaREyEpWaLyqh+0Npv05SI8mTJf4DEcawnEny6RjM+etmsVjUUiz4o+jfS1ki12oiH2wnsf9NM+uIoq5ihAL9z9ik64tQ0yvJu23ifx6Gn6MglYXCl9ItGu1Bw7rNW/nbZ+azueEA3Ttr+fXji1n00mssnr+c7j2VfOX5d7jwk68rdWi4kvaqF4Yr7F5gWPIoKXVZwcAIGYmKIjFHsa85NsZaQ/K0UDO+otQQhPKgclMq/hdG8YHfp6JfolbiJJIDt4kGyZyMXnQt1cKUVZU951u8z0nr0Ot6KhRbphY9/JQC1/VSy2SWZDB+qwJgPpJPUPPdCMfPV7jiNMqFTzRZg6hpWLd5J2fNms3iHd+zYu1GfnLZY1zwmz/yy4f/zh82r+NzT7/KXz3+zqcGNIyhvdpCHmk5GWpgHbOq+lcbqQ+Dgt6gkYrFuiWtLyqMd7Ge5YKa1dKqLnIbtbpD4QxcSH1lveKcu0n+mTbL4pKcQLUSqEFYZnWQG6Ur7AEt9+aVFs5qeuAH8BGAl6HlmfRbDOpEAN9Z9LlUCHGOHbMjgBsAnCk9+tKhuf9uhRa5/KqJh2ywLstvAJwHze05U/rTbAPwMTRvX7N0dsMB3Cn9A3rJOakCsBlaUqC3hBA1FmOImoYv12788+tv75n0y8kCffr0QPp+Hxqr3ajuBJSV12PNN72wdsuuT78snHKW2aaDljl8HID+0MIQWqGFQVRD81b9GFppinqDPkbC2qv1YyHEuREwkW6wju1aIYSYYLPfUwHcDOB06V/SCKBCOkW+IYRYaYLbE8DtAPIADJCOljVy/T+R619igt8ZmqfsZOlo10X6ldTKOf8eWtzYezp1Z+z4e50LLeP/OGhZ8zOhBe7tl/vsKwBvCyEsPZKFxcuS5MvOkM5QQ+RGCjKXA3JwldJrcA2A1eEFk+Lw34ETR08ZlpD5zJbB/TqKEUMdSE9zoskNFO8mdu5wonqvH/R+tHbrpmmjfk7jkh/BGQCmSSZn5aD1pBDi7tAf8ovypkPL/PVcQW7hbVbvzC/K6ys/rjIAJxTkFnrjO+wgmOaFkMWJPkRI+rU4/IwWlyloqkTg26p05+bvgEQnwADhaQZ8LX60NG9F9y79Trpqyr/n1HrmP1T00T/3/8QZSDdoqT6nS+lIFb42kJxbACTmF+X1A9BQkFtYp8NAHNC8RJNk+5b4zrLJSOLw84VzTr97fGbClf9qcvR01rkJ+gGXEKAfcEBA+APonNELxw7NEFNvLr+18O9Tp5x1StvI5V8U1P4EGUgagAcB3CI/akrR/lV5hbVyvz/MNb4gt3AegHn5RXm3QsvB8RiAWTq4OdDKn64uyC3Miu+sOCM5amDk8aenTjh+6oIdu9t6TbryO+zZ3Q1r3u8LOABCoNVJZGUmYOy5Seg/pBzb1lfDVZ3TJ0F8OgzAFyEfcCYOTV3wP0KIP8ln+3CwAtw5Qoil1MIQhumQVA9gO7QaKAUh/R/Whw4TOUFKxH3lT+8AuF8IsZVaEfA/W0zHPiFEqY6kkSalDEKrFdOaX5SXBa0ecR9ouV/2AQiaU535RXmdAAQKcgvr47sszkiOeHDAibqGtg7jR3VB8erN6N7LhRHdOiAJneAEkOAEhMOP1BoXSkt7oWRHCsr8b/x5D5atbieSOkKL7l5Ask0I8Y6iJHIctBwy6dAUvNcKIUKjYUfC2hhgFPH7nLwibYemzJwBzcCwTTLDrdCU3MEcqwOhKSHXyfdizNjxTgDnALgRmjI0ZpDWoQPuuecuOBxOPPTwI2htbVXGnTlzJk4d0B+O5sOzDTAhAb7eGk921tchacd2gAH4+g9AW9fukIzVL+flUWg1qPcNHph93Y6dpS8DSBg8MPvXcUZyFMDaDZ82JzvnjinfcNuXHcX5XbwdiA4pAkkJQCAg0OIGmpsdaClxwt/mwX53MUYNP33yuqbvMrZik9JpK4SwShWxGMD50BT0i6BZLyA/unes+qCW4Ht+CKOYGcZEAE3hagVrwiSRwZKxhRoMduFgGRUvNAtb0GCQAE3B2iAZTnJ+Ud5JAGp2/qF2j0gRqZLJnBDLNUztkIoJEybA5XLh0cces8VIAKLDskVIeudVgNJoKhyAEGgbezZq7/4jEneVoOPsB+Eo2wD4fWDXIWi69T40jxwVyoCfAnAhNGsVoFlxkwHEGcnRACccP845KHPsJUl1nbu497eB3gT4XEBKCpDg0hSujjYBtAawp64MKZn1mNj7vCFDfLcsoaMtd9mqhZZ6EpVriUyItZ3kUqnLAEKUpBZ9/AKa6RPymqFXeU/FXLwqhIk4ADwPzaQeLAD+VEFu4dv5RXkvQjO3d5XXm/ek7qWuILewf35R3iBoGf2GQyu+/pxvQ+DOpLFOSiaDS/OnoVevnigt3YX+/fujuaUZH37wISqr9sDpdOKKyy9FVlYWysp2o1+/fvB4PFi0eDFOO+1UdOnSBXUH6rBw4buobzg0c8cv8vLQp09vVFZW4d333oPX68PwYUORm3s+amr2Ye2332LixLNQU12Dgrdk6hG/H4Feg9Fw+yzA4UDKyuVIWvgymvOmAAE/0hfMg6irQf2T8+FoqEP6Q7egw8vPoOW5uTvpSngImrm6QUptwYRa02CQCyXOSI5AGNd15qOdvOffU98GILkJbMuEEAKtHu1+4PMBPg/g9vrg9/tRzS1ffV52fM7Zw8aOOTXrsseWYeGNMVKSOqDliQn94HcpoodWvV8RnqVP+jpNsujDHWQk+UV5PaUUckBKGG6pu+mTX5R3lnzWIq8vDVLE3wbAK59nhfTZAiAwvLDrgMr59ad5f/CPI4nzJp+HEcccg6qqKjQ1NWHQoEE4e9IkXH/9jfB4vcjLy0P//v1RUVEBn8+H7OxsXHzxVDQ2NsHn86Jv374YO3YMbr3t9oPXVIcDF154AdLS0tCjRw/kHJeDWbPux/Dhw5Gfn4/Kykrk509D165dsWnTJiwoeAuAgGf0ePiOyYE3eyAS9lYhcen78F56C1qGjwAg0PDrGRDea9DavScSd5cCThfgSgAgUqFlmtsNYAU0t4/WHTtL3x88MPtD4+t0HI4ouOiM2yd0d515d8X+A9jsmD034KwlHYTDBQQCQGsrEPALEAScAq2JNWx0fHfr9rYVb60oDqD2QJ9TY0TKefKuvTFECiGApxXxQ827elegRxQOwqKQqgdPS/1GDrQEUDnyinM1NCexUdBSDfaROpJ8+fcS+fwR2c9uSc95EPg+8/SUayH9sYJOWYsWLcK1192AyspK9O7dG2PHHZpKdsGCAtx0829RV1ePlJQUPDtnDm6beTt8Ph+GDx+O7t0OOrwGAgH8/g/34oEHH0IgEMCoUaPgcBz8bDt37oyKigqsWvUF1q1bJ0VBwDNsBJpPHguASPtwIUR9NdxnnfOfK05rt+7w9ctGxjtvouN9N4MdOqHpprtAl6sHtAqb+VIZPQNa9reEuLL1KII+SWffWL8/QTQ6dsHv8I9Iy+gqEv0OOAXgchBtfqClRcArWtCa1ACvd48QLl92srPfGXU+B8qbyj836d4fIVkN0DxbnxBCLFbECU18lUfyf6HVXkoEcB/UUhu+dIjiQKO/Rv5Nk9eYNimZVIe0Aw4mQm6RDGY/NOfLeqkAPgAgOyHDuQlEsWRIAACPxwMGAvD5fBBCICnx0EgIj8eDpqYm+P1tIAl3UxMa6htAEk6nE64EF7y+g/5uBw4cgMvl0p47HHC5Dn7T1dXVuHHGTRBCBK+Th7wrsaoSiYXz0DppGlq7HJ5Az9+tO/zHjYPr6yVI3LgeniHDdtOVMAdaNj83NJN7m9QdIS6RHCVQW++paRBVra2uvT4kelbUJx+AP8MDRyeiLR3wpgbgyXDDm1kDX8ZeiAyASGq+6u7Up8ZO3/DFG5+dn2OSpcttg5TF4iB0FEKcdVhqPnMIT0s5C5or/G6py7CCFUKI0PwmTnmqPgMt2/ybUiLpI/92kxJIF/n/GfI60yD/dgr+f0Fu4RnQUlMmkOgF62JV7QZ+vx8+E0Vs0sb1QEs1fCeeDASZjc+HpJJiJO4qQdPEydh/1/0IDB6J5Ll/QtIPW5uhear7APgHD8x+Y/DA7AWDB2a3xSWSowjmfzV15oRRN/3dD1dXH0vW7nMuucCXMnpYRnIvOIQDvrYWuL21aPHuQyua4Wksh8Pf4j33/DEn4mDOzqAFIzwjXdWPOJRF0GJVIgG3jsRSI+n3FOQWtuYX5XmkdLFOSiNVUsnagIPm5p5Sn1ICrSiVU35kkKe0x9XBUQwHKhBQKuURMaSmpkAIgUCA8PvbVBRUcHhakLB1E+AH/BkZEG2toCsBjmY3Oj44E/7Bx+HAHbPg8HmBpgYAAkxKGQjN5FsDYDkUS1TEGckRBsNyTnQh0+vJyZlyU1nZxu/8gdY1/tSGYXV0w+lMgN/VhlaHG0npTriYAmdaV6Q6T7prQcH7JZfm/xIkIYQYJ304JoZ03YYQZ7UfAV4D8HspMdjS8QK4RQjxg87vPXCwdkyilDyWFeQW6ia+zi/KSyzILfTJfw+CZv4MWrQ88vvp7EgR8/1uXonDLBoi6klwOBy4/75ZyM4eAIfDgc2bN8Hvt75hOhvr0fm+O+EoXQs4gfTZD8B1/e1oPHMS/JmZ8Ey7Dil/fRBZd5RA+DwQ1Vvhm3orfP2yG6H5kNRKZoo4IzkK4cSTZ72YnDbgerc3AZ26T7ikpaUO3hY3srIGYOeOz9DW5kW37scgK6sfhg/pCb/fh97dvMclJ22aAiDH5/OdkpSU5MLhZSkfM4s2jjUIIRpJXiklE9USGAEAM4QQr+k8q4ZWkiRYTeAraKbg/flFeZOhFZ1KA1BVkFu4Pr8oLwHA9PyivKCCo6PED2bhbwSwVAiUwIkNQoh/VlRUuJKTk7F//34ESJSXl4MMoK6+AYFAAOXl5QgEAqivrwdJlJWVoS+ncRIAAAGsSURBVL6+Hm63G36/H7t27YLD4YDX40WrrxWlpaVISkrCoEGDQBLLly/HM8/OgcPhQH19PUpLS1FeXg6HOFxDQacLbeMnAKMPptf1d876D4NrPO8X8HfMRPLHHwCtXviunAH3aWeCLlfx4IHZtispivind2TBhfnzPkhKG3hBq6cBgwePx/r1RQDb0K//OKxfO7cxJUXMS0lJ3ZKeOWT6+LHnnbxl21YAgbmvPH/K9O3bf8gcNGjgvQ6H4yIpCbRB8/B8Tgjxz0MlZ0sX+cVCiMnm0reSi/wZ0Gq79LUY+ibJRFYZSBdOqRP0F+QWBkJ+/x2AZ6GZeocCeLMgt/Bq6UJfEaL03SHH5ijILWyTuA4ALMgt5NG+7+ISyREGVbvfuyo5pduFDpHWtSTB8VTA39jkdW97vLKSFwjUP75y6QsLAeCUM694Z3Hd7luaGrZ97vf7HQAwdOiQOnmd+L2CxNBF57fhdmhV8I6FEGIFtbq406H5lpwALW9GE4BSaNagtwEsMavQV5Bb6Ie+1WkHgHdxMF9M0KXeB63eULD63D7JgAIhfQbiO06D/wc67LOkme5m0wAAAABJRU5ErkJggg=='
..'">'
}
function ui.logo(uiManager)
return uiManager:Label{
ID = "",
WordWrap = false,
Weight = 0,
MinimumSize = {274, 63},
ReadOnly = true,
Flat = true,
Alignment = { AlignHCenter = false, AlignTop = true, },
Text = ui.logo_string,
}
end
return ui
-- ui.manager = fu.UIManager
-- ui.dispatcher = bmd.UIDispatcher(ui.manager)
-- function ui.RunLoop()
-- print("ui Run ...")
-- ui.dispatcher:RunLoop()
-- end
-- function ui.ExitLoop()
-- print(".. ui Exit")
-- ui.dispatcher:ExitLoop()
-- end
-- local ui = {
-- chosenInstallModeOption = nil,
-- windowGeometry = { 100, 100, 800, 400 },
-- targetIsGitRepo = nil,
-- }
-- function ui.selectFusesDialog(params)
-- assert(params~=nil)
-- assert(params.fuses~=nil)
-- local thumbWidth=107 -- 160
-- local thumbHeight=60 -- 90
-- local win = ui.dispatcher:AddWindow({
-- ID = "ShaderInstallMain",
-- WindowTitle = params.windowTitle,
-- Geometry = { 100, 100, 700, 400 },
-- ui.manager:VGroup {
-- ui.manager:HGroup {
-- Weight = 0,
-- ui.logo(),
-- ui.manager:HGap(0,1),
-- ui.manager:Label{
-- Weight = 0,
-- ID = "Thumbnail",
-- MinimumSize = {thumbWidth, thumbHeight},
-- Alignment = { AlignHCenter = false, AlignTop = true, },
-- WordWrap = false, ReadOnly = true, Flat = true, Text = '',
-- },
-- },
-- ui.manager:VGap(5),
-- ui.manager:Tree {
-- ID = 'Files',
-- Weight = 2,
-- SortingEnabled=true,
-- -- UpdatesEnabled=true,
-- Events = {
-- -- ItemClicked=true,
-- ItemDoubleClicked=true,
-- -- ItemActivated=true,
-- CurrentItemChanged = true,
-- },
-- MinimumSize = {600, 200},
-- },
-- ui.manager:VGap(5),
-- ui.manager:HGroup{
-- Weight = 0,
-- ui.manager:Label {
-- ID = 'Error',
-- Weight = 3.0,
-- Alignment = { AlignHCenter = false, AlignVTop = true, },
-- WordWrap = false,
-- },
-- ui.manager:HGap(0,1),
-- ui.manager:Button{ ID = "Install", Text = "Install" },
-- ui.manager:Button{ ID = "Cancel", Text = "Cancel" },
-- },
-- },
-- })
-- local itm = win:GetItems()
-- function win.On.Install.Clicked(ev)
-- win:Hide()
-- params.onInstall(params.fuses)
-- -- g_chosenInstallModeOption.Procedure(params.ListOfFuses)
-- end
-- function win.On.Cancel.Clicked(ev)
-- win:Hide()
-- ui.ExitLoop()
-- end
-- function win.On.ShaderInstallMain.Close(ev)
-- win:Hide()
-- ui.ExitLoop()
-- end
-- function win.On.Files.ItemDoubleClicked(ev)
-- local fuse=params.fuses.get_fuse(ev.item.Text[0],ev.item.Text[1])
-- if fuse~=nil then
-- -- bmd.openurl("https://www.shadertoy.com/view/"..fuse.shadertoy_id)
-- bmd.openurl('https://nmbr73.github.io/Shadertoys/Shaders/'..fuse.file_category..'/'..fuse.file_fusename..'.html')
-- end
-- end
-- local defaultInfoText=""
-- function win.On.Files.CurrentItemChanged(ev)
-- print("CurrentItemChanged "..ev.item.Text[1])
-- local fuse=params.fuses.get_fuse(ev.item.Text[0],ev.item.Text[1])
-- if fuse==nil then return end
-- itm.Thumbnail.Text='<img src="file:/Users/nmbr73/Projects/Shadertoys/Shaders/'
-- ..fuse.file_category..'/'..fuse.file_fusename..'_320x180.png" width="'..thumbWidth..'" height="'..thumbHeight..'" />'
-- itm.Error.Text = fuse.error and '<span style="color:#ff9090; ">'..fuse.error.."</span>" or defaultInfoText
-- end
-- function win.On.Files.ItemClicked(ev)
-- print("clicked")
-- -- local fuse=params.fuses.get_fuse(ev.item.Text[0],ev.item.Text[1])
-- -- if fuse==nil then return end
-- -- itm.Thumbnail.Text='<img src="file:/Users/nmbr73/Projects/Shadertoys/Shaders/'
-- -- ..fuse.file_category..'/'..fuse.file_fusename..'_320x180.png" width="'..thumbWidth..'" height="'..thumbHeight..'" />'
-- -- itm.Error.Text = fuse.error and '<span style="color:#ff9090; ">'..fuse.error.."</span>" or defaultInfoText
-- end
-- function win.On.Files.ItemActivated(ev)
-- print("activated")
-- local fuse=params.fuses.get_fuse(ev.item.Text[0],ev.item.Text[1])
-- if fuse==nil then return end
-- itm.Thumbnail.Text='<img src="file:/Users/nmbr73/Projects/Shadertoys/Shaders/'
-- ..fuse.file_category..'/'..fuse.file_fusename..'_320x180.png" width="'..thumbWidth..'" height="'..thumbHeight..'" />'
-- itm.Error.Text = fuse.error and '<span style="color:#ff9090; ">'..fuse.error.."</span>" or defaultInfoText
-- end
-- local hdr = itm.Files:NewItem()
-- hdr.Text[0] = 'Category'
-- hdr.Text[1] = 'Fuse Name'
-- hdr.Text[2] = 'Author'
-- hdr.Text[3] = 'Port'
-- itm.Files:SetHeaderItem(hdr)
-- itm.Files.ColumnCount = 4
-- itm.Files.ColumnWidth[0] = 120
-- itm.Files.ColumnWidth[1] = 400
-- itm.Files.ColumnWidth[2] = 80
-- itm.Files.ColumnWidth[3] = 60
-- -- g_useShortcutPrefix = itm.UseShortcutPrefix
-- -- g_useShadertoyID = itm.UseShadertoyID
-- -- g_useCategoryPathes = itm.UseCategoryPathes
-- local numFuses=0
-- for i, f in ipairs(params.fuses.list) do
-- -- print("add "..f.file_category.."/"..f.file_fusename)
-- local newitem = itm.Files:NewItem()
-- newitem.Text[0] = f.file_category
-- newitem.Text[1] = f.file_fusename
-- newitem.Text[2] = f.shadertoy_author
-- newitem.Text[3] = (f.error and '🚫 ' or '')..f.dctlfuse_author
-- itm.Files:AddTopLevelItem(newitem)
-- if f.error==nil then
-- numFuses=numFuses+1
-- end
-- end
-- itm.Files:SortByColumn(1, "AscendingOrder")
-- itm.Files:SortByColumn(0, "AscendingOrder")
-- defaultInfoText=numFuses.." valid fuses found"
-- -- local entry = params.ListOfFuses.head -- LIST_OF_FUSES.head
-- -- local num_wip = 0
-- -- while entry do
-- -- if entry.Install then
-- -- local newitem = itm.Files:NewItem()
-- -- newitem.Text[0] = entry.File
-- -- itm.Files:AddTopLevelItem(newitem)
-- -- else
-- -- num_wip = num_wip +1
-- -- end
-- -- entry=entry.next
-- -- end
-- -- itm.NumberOfFusesLabel.Text= (params.ListOfFuses.len - num_wip) .." Fuses to be installed".. (num_wip and " ("..num_wip.." ignored)" or "")
-- return win
-- end
-- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- function ui.chooseInstallOption(params)
-- assert(params.targetIsGitRepo ~= nil)
-- -- local targetIsGitRepo=false
-- if params==nil then params={} end
-- local optionNotImplemented=[[
-- <p style="color:#ffffff; ">
-- <span style="color:#ff9090; ">This option has not been implemented yet.</span>
-- The whole thing is work in progress. And this option is only here as a reminder.
-- </p>
-- ]]
-- local options=
-- {
-- { -- Mode = MODE_NONE,
-- Label = "- chose installation mode -",
-- Enabled = false,
-- Procedure = nil,
-- Text = [[
-- <p>This script is menat to install the shader fuses, or to create installation scripts to install the shader fuses.
-- Use the select box on top to chose an installation mode and to see further details on the respective method.</p>
-- ]]
-- .."<p>"..(params.targetIsGitRepo and 'Accessing the Git repo' or 'Working on the ZIP').."</p>"
-- ,
-- },
-- { -- Mode = MODE_LOCALCOPY,
-- Label = "Local Copy",
-- Enabled = not(params.targetIsGitRepo) and params.localCopySelected~=nil,
-- Procedure = params.localCopySelected,
-- Text = [[
-- <p>If you have downloaded and extracted(!) the whole repository as a ZIP file, then this mode should help you to
-- create a local copy of the fuses in the correct target directory. In this case the script creates the <em>Shadertoys<em>
-- subdirectories in your DaVinci Resolve's / Fusion's <em>Fuses</em> directory and copies all the .fuse files and only
-- these to that directory.</p>
-- ]]..(params.targetIsGitRepo and [[
-- <p style="color:#ffffff; ">
-- <span style="color:#ff9090; ">This option is not available ...</span>
-- It seems that you are managing our Shadertoy Fuses using Git already. That's awesome! Forking and/or cloning us
-- on GitHub obviously is the right and more pro way of doing things. Just use a 'git pull' in your 'Shadertoys'
-- directory and you are up to date and good to go. Looking forward to your pull requests maybe contributing some
-- beatutiful shaderstoys?!!
-- </p>
-- ]] or "")
-- .. (params.localCopySelected==nil and optionNotImplemented or ''),
-- },
-- {
-- Label = "Refresh Overviews",
-- Enabled = params.targetIsGitRepo and params.refreshOverviewsSelected~=nil,
-- Procedure = params.refreshOverviewsSelected,
-- Text = [[
-- <p>This one is to update the markdown files showing overview lists for all the fuses.</p>
-- ]]..(not(params.targetIsGitRepo) and [[
-- <p style="color:#ffffff; ">
-- <span style="color:#ff9090; ">This option is not available ...</span>
-- This is meant to refresh the repository's overviews - so it makes only sense to call it on the repsotory itself.
-- </p>
-- ]] or "")
-- .. (params.refreshOverviewsSelected==nil and optionNotImplemented or ''),
-- },
-- { -- Mode = MODE_SINGLEINSTALLERS,
-- Label = "Single Installers",
-- Enabled = params.onSingleInstallersSelected~=nil,
-- Procedure = params.onSingleInstallersSelected,
-- Text = [[
-- <p>This options generates a separate, fully self contained '<tt>*-Installer.lua</tt>' script for each fuse.
-- This allows the fuses to be distributed independently of the repository,
-- whilst still providing the convenience of not having to copy the Fuse to the specific pathes manually.
-- Just drag and drop such an installer script onto your DaFusion's working area and the script will guide
-- you through the installation.</p>
-- <p style="color:#ffffff; ">
-- Please note that hereby any such installer is overwritten. Just run this option from time to time
-- on the repository to make the installers contain the most recent versions of the fuses.
-- </p>
-- ]]
-- .. (params.onSingleInstallersSelected==nil and optionNotImplemented or ''),
-- },
-- { -- Mode = MODE_CREATEINSTALLER,
-- Label = "Create Installer",
-- Enabled = params.createInstallerSelected~=nil,
-- Procedure = params.createInstallerSelected,
-- Text = [[
-- <p>The 'Create Installer' is to create a single Lua script that can be used to install all the fuses.
-- It is intended to be provided in particular as a separate download with no need to copy the ZIP or
-- clone the repository.</p>
-- ]]
-- .. (params.refreshOverviewsSelected==nil and optionNotImplemented or ''),
-- },
-- { -- Mode = MODE_PREPARESUGGESTION,
-- Label = "Prepare WSL Suggestion",
-- Enabled = params.prepareSuggestionSelected~=nil,
-- Procedure = params.prepareSuggestionSelected,
-- Text = [[
-- <p>Idea is to have the installer create copies of the Fuses without all the prefixes, debug settings,
-- additinal files, etc. This to end up with a directory structure that can be used in preparation of a
-- suggestion for integration into the WSL Reactor.</p>
-- ]]
-- .. (params.prepareSuggestionSelected==nil and optionNotImplemented or ''),
-- },
-- }
-- ui.chosenInstallModeOption = options[1]
-- local win = ui.dispatcher:AddWindow({
-- ID = "ShaderInstallSelect",
-- WindowTitle = "Shadertoys Installer - Select Installation mode ...",
-- Geometry = ui.windowGeometry,
-- -- Composition = comp,
-- ui.manager:VGroup {
-- -- ID = "root",
-- Weight=1,
-- ui.logo(),
-- ui.manager:VGap(10),
-- ui.manager:ComboBox{
-- ID = "ModeSelection",
-- Text = 'Install Mode Selection',
-- Weight = 0,
-- Events = { CurrentIndexChanged = true, Activated = true },
-- Items = { 'Foo' , 'Bar'},
-- },
-- ui.manager:VGap(10),
-- ui.manager:Label{
-- ID = "Description",
-- WordWrap = true,
-- Weight = 1,
-- ReadOnly = true,
-- Flat = true,
-- Alignment = { AlignHCenter = false, AlignTop = true, },
-- Text = ""
-- },
-- ui.manager:HGroup {
-- Weight = 0,
-- ui.manager:HGap(0,1),
-- ui.manager:Button{ ID = "Continue", Text = "Continue ..." },
-- ui.manager:HGap(5),
-- ui.manager:Button{ ID = "Cancel", Text = "Cancel" },
-- },
-- },
-- })
-- local itm=win:GetItems()
-- for i, option in ipairs(options) do
-- itm.ModeSelection:AddItem(option.Label)
-- end
-- function win.On.ModeSelection.CurrentIndexChanged(ev)
-- local index = itm.ModeSelection.CurrentIndex+1
-- local entry = options[index]
-- assert(entry ~= nil)
-- ui.chosenInstallModeOption=entry
-- itm.Continue.Enabled=entry.Enabled
-- itm.Description.Text=entry.Text
-- end
-- function win.On.Continue.Clicked(ev)
-- win:Hide()
-- -- showInstallMainWindow()
-- -- params.NextWindow:Show()
-- ui.chosenInstallModeOption.Procedure()
-- end
-- function win.On.Cancel.Clicked(ev)
-- ui.dispatcher:ExitLoop()
-- os.exit()
-- end
-- function win.On.ShaderInstallSelect.Close(ev)
-- ui.dispatcher:ExitLoop()
-- os.exit()
-- end
-- win:Show()
-- end
|
-- Get Off V1.0
-- By: Parvulster
-- Get Off Command
getoff = "/getoff"
vehicleusers = {}
function EntitySpawn(args)
if args.entity.__type == "Vehicle" then
local vehicle = args.entity
vehicleusers[vehicle:GetId()] = {}
end
end
function PlayerChat(args)
if args.text == getoff then
local vehicle = args.vehicle
if vehicle ~= nil then
local driver = vehicleusers[vehicle:GetId()].driver
if driver == args.player:GetId() then
local stunter = vehicleusers[vehicle:GetId()].stunter
if stunter ~= nil then
local position = stunter:GetPosition()
stunter:SetPosition(position)
end
end
end
end
end
function PlayerEnterStunt(args)
local vehicle = args.vehicle
vehicleusers[vehicle:GetId()].stunter = args.player:GetId()
end
function PlayerExitStunt(args)
local vehicle = args.vehicle
vehicleusers[vehicle:GetId()].stunter = nil
end
function PlayerEnterVehicle(args)
if args.is_driver then
local vehicle = args.vehicle
vehicleusers[vehicle:GetId()].driver = args.player:GetId()
end
end
function PlayerExitVehicle(args)
local vehicle = args.vehicle
if vehicleusers[vehicle:GetId()].driver == args.player:GetId() then
vehicleusers[vehicle:GetId()].driver = nil
end
end
Events:Subscribe("EntitySpawn", EntitySpawn)
Events:Subscribe("PlayerChat", PlayerChat)
Events:Subscribe("PlayerEnterStunt", PlayerEnterStunt)
Events:Subscribe("PlayerExitStunt", PlayerExitStunt)
Events:Subscribe("PlayerEnterVehicle", PlayerEnterVehicle)
Events:Subscribe("PlayerExitVehicle", PlayerExitVehicle) |
local drawableNinePatch = require("structs.drawable_nine_patch")
local utils = require("utils")
local crumbleBlock = {}
local textures = {
"default", "cliffside"
}
crumbleBlock.name = "MaxHelpingHand/CustomizableCrumblePlatform"
crumbleBlock.depth = 0
crumbleBlock.placements = {}
for _, texture in ipairs(textures) do
table.insert(crumbleBlock.placements, {
name = texture,
data = {
width = 8,
texture = texture,
oneUse = false,
respawnDelay = 2.0,
grouped = false,
minCrumbleDurationOnTop = 0.2,
maxCrumbleDurationOnTop = 0.6,
crumbleDurationOnSide = 1.0,
outlineTexture = "objects/crumbleBlock/outline",
onlyEmitSoundForPlayer = false,
fadeOutTint = "808080",
attachStaticMovers = false
}
})
end
crumbleBlock.fieldOrder = {"x", "y", "width", "crumbleDurationOnSide", "minCrumbleDurationOnTop", "maxCrumbleDurationOnTop"}
crumbleBlock.fieldInformation = {
fadeOutTint = {
fieldType = "color"
}
}
local ninePatchOptions = {
mode = "fill",
fillMode = "repeat",
border = 0
}
function crumbleBlock.sprite(room, entity)
local x, y = entity.x or 0, entity.y or 0
local width = math.max(entity.width or 0, 8)
local variant = entity.texture or "default"
local texture = "objects/crumbleBlock/" .. variant
local ninePatch = drawableNinePatch.fromTexture(texture, ninePatchOptions, x, y, width, 8)
return ninePatch
end
function crumbleBlock.selection(room, entity)
return utils.rectangle(entity.x or 0, entity.y or 0, math.max(entity.width or 0, 8), 8)
end
return crumbleBlock
|
require "Utilities/Enums"
require "Race"
Building = { race = nil, x = nil, y = nil, view = nil, health = nil, image = nil, level = nil, name = nil, defense = nil}
function Building:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function Building:Draw(tile_size, posX, posY, uiEndX, uiEndY)
love.graphics.draw(self.image, ((self.x + 1) - posX) * tile_size + uiEndX, ((self.y + 1) - posY) * tile_size + uiEndY)
end
function Building:SetImage(Image)
self.image = Image
end
function Building:NewTurn()
end |
local ucursor = require "luci.model.uci".cursor()
local json = require "luci.jsonc"
local server_section = arg[1]
local server = ucursor:get_all("firefly", server_section)
local v2ray = {
log = {
--error = "/var/log/v2ray.log",
loglevel = "warning"
},
-- 传入连接
inbound = {
port = tonumber(server.server_port),
protocol = "vmess",
settings = {
clients = {
{
id = server.vmess_id,
alterId = tonumber(server.alter_id),
level = tonumber(server.VMess_level)
}
}
},
-- 底层传输配置
streamSettings = {
network = server.transport,
security = (server.tls == '1') and "tls" or "none",
kcpSettings = (server.transport == "kcp") and {
mtu = tonumber(server.mtu),
tti = tonumber(server.tti),
uplinkCapacity = tonumber(server.uplink_capacity),
downlinkCapacity = tonumber(server.downlink_capacity),
congestion = (server.congestion == "1") and true or false,
readBufferSize = tonumber(server.read_buffer_size),
writeBufferSize = tonumber(server.write_buffer_size),
header = {
type = server.kcp_guise
}
} or nil,
httpSettings = (server.transport == "h2") and {
path = server.h2_path,
host = server.h2_host,
} or nil,
quicSettings = (server.transport == "quic") and {
security = server.quic_security,
key = server.quic_key,
header = {
type = server.quic_guise
}
} or nil
}
},
-- 传出连接
outbound = {
protocol = "freedom"
},
-- 额外传出连接
outboundDetour = {
{
protocol = "blackhole",
tag = "blocked"
}
}
}
print(json.stringify(v2ray,1)) |
#!/usr/local/bin/lua -i
local function name2node(graph, name)
local node = graph[name]
if not node then
-- Node does not exist, make a new one
node = {name = name, arcs = {}}
graph[name] = node
end
return node
end
function readgraph(filename)
local f = assert(io.open(filename, 'r'))
local graph = {}
for line in f:lines() do
-- split line into two names
local namefrom, arclabel, nameto = string.match(line, "(%S+)%s(%d+)%s(%S+)")
-- find corresponding nodes
local from = name2node(graph, namefrom)
local to = name2node(graph, nameto)
-- adds 'to' to the adjacent set of 'from'
from.arcs[#from.arcs+1] = {label = arclabel, target = to}
end
f:close()
return graph
end
-- Calculates the index of a parent
function parent(i)
-- this defaults the value to 1 for the root.
-- the root is its own parent
return math.max(i//2, 1)
end
-- Calculates the index of the left child
function left(i)
return 2 * i
end
-- Calculates the index of the right child
function right(i)
return ( 2 * i ) + 1
end
-- Swaps to elements in a table
function swap(heap, l, r)
local temp = heap[l]
heap[l] = heap[r]
heap[r] = temp
end
-- Turns a subset of a list into a heap
-- i is the index of the root of the subheap
function minHeapify(heap, i)
i = i or 0
local l = left(i)
local r = right(i)
local smallest = i
-- locate the smallest node (either the root or children)
if l <= #heap and heap[l] < heap[i] then
smallest = l
end
if r <= #heap and heap[r] < heap[i] then
smallest = r
end
-- If the root violates the rule, swap to fix and recurse
if smallest ~= i then
swap(heap, i, smallest)
minHeapify(heap, smallest)
end
end
-- Pushes a new value into the minHeap
function minHeapPush(heap, node, priority)
local currentIndex = #heap + 1
heap[currentIndex] = { node=node, priority=priority }
while currentIndex > 1 do
local p = parent(currentIndex)
if heap[p].priority > heap[currentIndex].priority then
-- Bubble up
swap(heap, p, currentIndex)
currentIndex = p
else
return
end
end
end
-- Finds and decreases the priority of a node in the minHeap
function minHeapDecrease(heap, node, priority)
local found = nil
for i,v in ipairs(heap) do
if v.node == node then
found = i
break
end
end
if found then
heap[found].priority = priority
local currentIndex = found
while currentIndex do
local p = parent(currentIndex)
if heap[p].priority > heap[currentIndex].priority then
swap(heap, p, currentIndex)
currentIndex = p
else
break
end
end
return true
else return false
end
end
-- Retrieves the minimum priority node in a minHeap
function minHeapPop(heap)
if not heap then
return nil, nil
end
local element = table.remove(heap, 1)
return element.node, element.priority
end
-- Constructs a path to the destination from a parents table
function buildPath(parents, dest)
local path = {}
local current = dest
table.insert(path, dest)
while parents[current] ~= current do
table.insert(path, 1, parents[current])
current = parents[current]
end
return path
end
-- Runs dijkstra's algorithm from the a start node to the destination
function dijkstra(start, dest)
local q = {} -- the minHeap
local dists = {} -- tracks the distance to each node
local visited = {} -- tracks which nodes are visited
local parents = {} -- tracks the parent of each node
minHeapPush(q, start, 0)
dists[start] = 0
parents[start] = start -- the root's parent is itself
while #q > 0 do
local current, dist = minHeapPop(q)
if current == dest then
return buildPath(parents, dest)
end
for i,v in ipairs(current.arcs) do
if not visited[v.target] then
local tentativeDist = dist + v.label
if not dists[v.target] then
minHeapPush(q, v.target, tentativeDist)
dists[v.target] = tentativeDist
parents[v.target] = current
elseif tentativeDist < dists[v.target] then
minHeapDecrease(q, v.target, tentativeDist)
dists[v.target] = tentativeDist
parents[v.target] = current
end
end
end
visited[current] = true
end
return nil
end
function printpath(path)
for i = 1, #path do
print(path[i].name)
end
end
function test()
local g = readgraph("14.3.graph")
local a = name2node(g, "a")
local d = name2node(g, "d")
local p = dijkstra(a, d)
if p then printpath(p) end
local e = name2node(g, "e")
print("NOPATH gives", dijkstra(a,e))
end
|
--鉄獣の凶襲
--
--Script by JustFish
function c101102053.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetCountLimit(1,101102053+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c101102053.sptg)
e1:SetOperation(c101102053.spop)
c:RegisterEffect(e1)
end
function c101102053.spfilter1(c,e,tp)
return c:IsFaceup() and c:IsRace(RACE_BEAST+RACE_BEASTWARRIOR+RACE_WINDBEAST)
and Duel.IsExistingMatchingCard(c101102053.spfilter2,tp,LOCATION_DECK,0,1,nil,e,tp,c:GetAttack(),c:GetRace())
end
function c101102053.spfilter2(c,e,tp,atk,race)
return c:IsRace(RACE_BEAST+RACE_BEASTWARRIOR+RACE_WINDBEAST) and c:IsAttackBelow(atk) and not c:IsRace(race)
and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c101102053.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c101102053.spfilter1(chkc,e,tp) end
if chk==0 then return Duel.GetMZoneCount(tp)>0
and Duel.IsExistingTarget(c101102053.spfilter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c101102053.spfilter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c101102053.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c101102053.spfilter2,tp,LOCATION_DECK,0,1,1,nil,e,tp,tc:GetAttack(),tc:GetRace())
local tc=g:GetFirst()
if tc then
Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EFFECT_DISABLE_EFFECT)
tc:RegisterEffect(e2)
Duel.SpecialSummonComplete()
end
end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,0)
e1:SetTarget(c101102053.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c101102053.splimit(e,c)
return not c:IsType(TYPE_LINK) and c:IsLocation(LOCATION_EXTRA)
end
|
local M = {}
function M.config()
require('gitsigns').setup {
signs = {
add = { hl = 'GitSignsAdd', text = '+', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn', },
change = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn', },
delete = { hl = 'GitSignsDelete', text = '_', show_count = true, numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn', },
topdelete = { hl = 'GitSignsDelete', text = '‾', show_count = true, numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn', },
changedelete = { hl = 'GitSignsChange', text = '~', show_count = true, numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn', },
},
count_chars = {
[1] = '',
[2] = '₂',
[3] = '₃',
[4] = '₄',
[5] = '₅',
[6] = '₆',
[7] = '₇',
[8] = '₈',
[9] = '₉',
['+'] = '₊',
},
numhl = false,
linehl = false,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
['n ]c'] = {
expr = true,
'&diff ? \']c\' : \'<cmd>lua require"gitsigns".next_hunk()<CR>\'',
},
['n [c'] = {
expr = true,
'&diff ? \'[c\' : \'<cmd>lua require"gitsigns".prev_hunk()<CR>\'',
},
['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['n <leader>hR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line()<CR>',
},
watch_index = { interval = 1000 },
current_line_blame = false,
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
use_decoration_api = true,
use_internal_diff = true,
}
-- vim.cmd [[autocmd User FormatterPost lua require'gitsigns'.refresh()]]
end
return M
|
local class = require "com/class"
local Console = class:derive("Console")
local Vec2 = require("src/Essentials/Vector2")
function Console:new()
self.history = {}
self.command = ""
self.open = false
self.active = false
self.backspace = false
self.BACKSPACE_FIRST_REPEAT_TIME = 0.5
self.BACKSPACE_NEXT_REPEAT_TIME = 0.05
self.backspaceTime = 0
self.MAX_MESSAGES = 20
self.font = love.graphics.newFont()
self.consoleFont = love.graphics.newFont("unifont.ttf", 16)
end
function Console:update(dt)
if self.backspace then
self.backspaceTime = self.backspaceTime - dt
if self.backspaceTime <= 0 then
self.backspaceTime = self.BACKSPACE_NEXT_REPEAT_TIME
self:inputBackspace()
end
else
self.backspaceTime = self.BACKSPACE_FIRST_REPEAT_TIME
end
end
function Console:print(message)
table.insert(self.history, {text = message, time = totalTime})
local logText = "[CONSOLE] "
if type(message) == "table" then
for i = 1, #message / 2 do
logText = logText .. message[i * 2]
end
else
logText = logText .. message
end
print(logText)
end
function Console:setOpen(open)
self.open = open
self.active = open
end
function Console:toggleOpen(open)
self:setOpen(not self.open)
end
function Console:draw()
local pos = Vec2(5, displaySize.y)
local size = Vec2(600, 200)
love.graphics.setColor(1, 1, 1)
love.graphics.setFont(self.consoleFont)
for i = 1, self.MAX_MESSAGES do
local pos = pos - Vec2(0, 30 + 20 * i)
local message = self.history[#self.history - i + 1]
if message then
local t = totalTime - message.time
if self.open or t < 10 then
local a = 1
if not self.open then
a = math.min(10 - t, 1)
end
dbg:drawVisibleText(message.text, pos, 20, nil, a)
end
end
end
if self.open then
local text = "> " .. self.command
if self.active and totalTime % 1 < 0.5 then text = text .. "_" end
dbg:drawVisibleText(text, pos - Vec2(0, 25), 20, size.x)
end
love.graphics.setFont(self.font)
end
function Console:keypressed(key)
-- the shortcut is Ctrl + `
if key == "`" and (keyModifiers["lctrl"] or keyModifiers["rctrl"]) then
self:toggleOpen()
end
if self.active then
if key == "backspace" then
self:inputBackspace()
self.backspace = true
end
if key == "return" then
self:inputEnter()
end
end
end
function Console:keyreleased(key)
if key == "backspace" then
self.backspace = false
end
end
function Console:textinput(t)
self:inputCharacter(t)
end
function Console:inputCharacter(t)
if not self.active then return end
self.command = self.command .. t
end
function Console:inputBackspace()
if not self.active then return end
self.command = self.command:sub(1, -2)
end
function Console:inputEnter()
local success = dbg:runCommand(self.command)
if not success then self:print("Invalid command!") end
self.command = ""
end
return Console
|
local M =
{
ai = 1,
}
return M |
-- load ShaguPlates environment
setfenv(1, ShaguPlates:GetEnvironment())
if ShaguPlates.libhealth then return end
local mobdb = {}
local target, dmg, perc, diff = nil, 0, 0, 0, 0
local UnitHealth, UnitHealthMax
local libhealth = CreateFrame("Frame")
libhealth.enabled = true
libhealth.reqhit = 4
libhealth.reqdmg = 5
libhealth:RegisterEvent("UNIT_HEALTH")
libhealth:RegisterEvent("UNIT_COMBAT")
libhealth:RegisterEvent("PLAYER_TARGET_CHANGED")
libhealth:RegisterEvent("PLAYER_ENTERING_WORLD")
libhealth:SetScript("OnEvent", function()
if event == "PLAYER_ENTERING_WORLD" then
-- create initial health cache tables
ShaguPlates_cache["libhealth"] = ShaguPlates_cache["libhealth"] or {}
mobdb = ShaguPlates_cache["libhealth"]
-- load enable state and set functions
libhealth.enabled = ShaguPlates_config["global"]["libhealth"] == "1" and true or nil
libhealth.reqhit = (tonumber(ShaguPlates_config["global"]["libhealth_hit"]) or 4)
libhealth.reqdmg = (tonumber(ShaguPlates_config["global"]["libhealth_dmg"]) or 0.5) * 100
end
-- return as we're not supposed to be here
if not libhealth.enabled then this:UnregisterAllEvents() return end
-- try to estimate mob health based on combat and health events
if event == "PLAYER_TARGET_CHANGED" then
dmg, perc = 0, _G.UnitHealth("target")
if UnitName("target") and UnitLevel("target") and _G.UnitHealthMax("target") == 100 then
target = string.format("%s:%d",UnitName("target"), UnitLevel("target"))
else
target = nil
end
elseif target and event == "UNIT_COMBAT" and arg1 == "target" then
if arg2 and arg2 == "HEAL" then return end
dmg = dmg + arg4
elseif target and event == "UNIT_HEALTH" and arg1 == "target" then
diff = perc-_G.UnitHealth("target")
if dmg > 0 and diff > 0 then
mobdb[target] = mobdb[target] or {}
if not mobdb[target][2] or diff > mobdb[target][2] then
mobdb[target][1] = ceil(dmg / diff * 100)
mobdb[target][2] = diff
mobdb[target][3] = mobdb[target][3] and mobdb[target][3] + 1 or 1
end
end
end
end)
-- core function to query the generated database
local unit, level, cur, max, dbstring
local function GetUnitHealth(self, unitstr)
unit = UnitName(unitstr)
level = UnitLevel(unitstr)
cur = _G.UnitHealth(unitstr)
max = _G.UnitHealthMax(unitstr)
-- return raw values if another addon is replacing global API calls
if cur > 100 or max > 100 or max < 100 then
return cur, max, true
end
-- return raw values if no unit data could be found (unlikely but happened...)
if not unit or not level then
return cur, max
end
-- query the database for known values
dbstring = string.format("%s:%s", unit, level)
if mobdb[dbstring] and mobdb[dbstring][1] and mobdb[dbstring][2] > libhealth.reqdmg and (not mobdb[dbstring][3] or mobdb[dbstring][3] > libhealth.reqhit) then
return ceil(mobdb[dbstring][1]/100*cur), mobdb[dbstring][1], true
end
-- return raw values as fallback
return cur, max
end
local function GetUnitHealthByName(self, unit, level, cur, max)
-- return raw values if another addon is replacing global API calls
if cur > 100 or max > 100 or max < 100 then
return cur, max, true
end
-- return raw values if no unit data could be found (unlikely but happened...)
if not unit or not level then
return cur, max
end
-- query the database for known values
dbstring = string.format("%s:%s", unit, level)
if mobdb[dbstring] and mobdb[dbstring][1] and mobdb[dbstring][2] > libhealth.reqdmg and (not mobdb[dbstring][3] or mobdb[dbstring][3] > libhealth.reqhit) then
return ceil(mobdb[dbstring][1]/100*cur), mobdb[dbstring][1], true
end
-- return raw values as fallback
return cur, max
end
-- add api calls to global tree
ShaguPlates.libhealth = libhealth
ShaguPlates.libhealth.GetUnitHealth = GetUnitHealth
ShaguPlates.libhealth.GetUnitHealthByName = GetUnitHealthByName
|
return {'anzegem','anzegemse'} |
////////////////////////////////////////
// Maax´s Libary (MLIB) //
// Coded by: Maax //
// //
// Version: v1.0 (Workshop) //
// //
// You are not permitted to //
// reupload this Script! //
// //
////////////////////////////////////////
function MLIB:CreateFont( name , size )
surface.CreateFont( name, {
font = "Roboto",
size = size or "20",
})
end
--[[
Some old fonts I from MLIB v1.0
]]--
surface.CreateFont( "mlib.basicsmall", {
font = "Arial",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.basicmedium", {
font = "Arial",
size = 32,
weight = 800
} )
surface.CreateFont( "mlib.basicbig", {
font = "Arial",
size = 40,
weight = 800
} )
surface.CreateFont( "mlib.basicbig_x", {
font = "Arial",
size = 64,
weight = 800
} )
surface.CreateFont( "mlib.advancedsmall", {
font = "Thahoma",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.advancedmedium", {
font = "Thahoma",
size = 32,
weight = 800
} )
surface.CreateFont( "mlib.advancedbig", {
font = "Thahoma",
size = 64,
weight = 800
} )
surface.CreateFont( "mlib.headmedium", {
font = "Arial",
size = 64,
weight = 800
} )
surface.CreateFont( "mlib.headbig", {
font = "Thahoma",
size = 64,
weight = 800
} )
surface.CreateFont( "mlib.toolhead", {
font = "Arial",
size = 32,
weight = 800
} )
surface.CreateFont( "mlib.hud_text", {
font = "Arial",
size = 20,
weight = 800
} )
surface.CreateFont( "mlib.tooltext", {
font = "Thahoma",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.hudtext:small", {
font = "Thahoma",
size = 10,
weight = 800
} )
surface.CreateFont( "mlib.hudtext:medium", {
font = "Thahoma",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.hudtext:big", {
font = "Thahoma",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.hudelement:small", {
font = "Arial",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.hudelement:medium", {
font = "Arial",
size = 16,
weight = 800
} )
surface.CreateFont( "mlib.hudelement:big", {
font = "Arial",
size = 34,
weight = 800
} )
surface.CreateFont( "mlib.npc:msmall", {
font = "Arial",
size = 28,
weight = 800
} )
surface.CreateFont("mlib.npc_small", {
font = "Roboto",
size = 32,
})
surface.CreateFont("mlib.npc_small01", {
font = "Roboto",
size = ScrH() * 0.025,
})
surface.CreateFont("mlib.npc_cardealer_small", {
font = "Roboto",
size = 32,
})
surface.CreateFont("mlib.npc_medium", {
font = "Roboto",
size = ScrH() * 0.016,
})
surface.CreateFont("mlib.npc_medium01", {
font = "Roboto",
size = ScrH() * 0.023,
})
surface.CreateFont("mlib.npc_big", {
font = "Roboto",
size = ScrH() * 0.019,
})
surface.CreateFont("mlib.npc_big", {
font = "Roboto",
size = 64,
})
surface.CreateFont("mlib.npc_big_x", {
font = "Roboto",
size = 32,
})
surface.CreateFont("mlib.notification", {
font = "Roboto",
size = 28,
})
surface.CreateFont("mlib.topbar", {
font = "Roboto",
size = 30,
})
surface.CreateFont("mlib.notification_small", {
font = "Roboto",
size = 20,
})
surface.CreateFont("mlib.default_x", {
font = "Tahoma",
size = 36,
})
surface.CreateFont("mlib.default_npc_head", {
font = "Default",
size = 80,
})
surface.CreateFont("mlib.default", {
font = "Tahoma",
size = 26,
})
surface.CreateFont("mlib.default_timer", {
font = "Default",
size = 28,
})
surface.CreateFont("mlib.default", {
font = "Default",
size = 26,
})
surface.CreateFont("mlib.default_xxl", {
font = "Default",
size = 36,
})
surface.CreateFont( "mlib.door_header", {
font = "Default",
size = 50,
})
surface.CreateFont("mlib.hud_default_text", {
font = "Default",
size = 26,
})
surface.CreateFont("mlib.textentry", {
font = "Default",
size = 20,
})
surface.CreateFont("mlib.promo_head", {
font = "Default",
size = 25,
})
surface.CreateFont("mlib.score_text", {
font = "Default",
size = 30,
})
surface.CreateFont("mlib.promo_btn", {
font = "Default",
size = 30,
})
surface.CreateFont("mlib.btn_text", {
font = "Default",
size = 20,
})
surface.CreateFont("DEFCON_HudHeader2", {
font = "Default",
size = 30,
})
surface.CreateFont("mlib.scoreboard_small", {
font = "Default",
size = 30,
})
surface.CreateFont("mlib.scoreboard_bar", {
font = "Default",
size = 30,
weight = 550
})
surface.CreateFont("mlib.scoreboard", {
font = "Default",
size = 36,
})
surface.CreateFont("mlib.terminal", {
font = "Default",
size = 40,
})
surface.CreateFont("mlib.hud_prp", {
font = "Default",
size = 22,
})
surface.CreateFont("mlib.hud_notfiy_head", {
font = "Default",
size = 40,
})
surface.CreateFont("mlib.escape_header", {
font = "Default",
size = 90,
})
surface.CreateFont("mlib.escape_btn", {
font = "Roboto",
size = 32,
})
surface.CreateFont("mlib.close_btn", {
font = "Tahoma",
size = 70,
})
surface.CreateFont("mlib.close_small", {
font = "Tahoma",
size = 56,
})
surface.CreateFont("mlib.help_system", {
font = "Tahoma",
size = 36,
})
surface.CreateFont("mlib.ticket_small", {
font = "Tahoma",
size = 20,
})
surface.CreateFont("mlib.broadcastentry", {
font = "Roboto",
size = 30,
})
surface.CreateFont("MLIB.Button", {
font = "Roboto",
size = ScreenScale(11.4),
width = 150
})
surface.CreateFont("MLIB.ListPanel", {
font = "Roboto",
size = ScreenScale(11.4),
width = 150
})
surface.CreateFont("MLIB.Head", {
font = "Roboto",
size = ScreenScale(12.4),
width = 150
})
surface.CreateFont("MLIB.CloseBtn", {
font = "Roboto",
size = ScreenScale(7.4),
width = 40
})
surface.CreateFont("MLIB.PopUPHead", {
font = "Roboto",
size = ScreenScale(15.4),
width = 150
}) |
require 'paths'
require 'rnn'
require 'nngraph'
local dl = require 'dataload'
assert(nn.NCEModule and nn.NCEModule.version and nn.NCEModule.version >= 4, "update dpnn : luarocks install dpnn")
require 'cunn'
--[[ command line arguments ]]--
cmd = torch.CmdLine()
cmd:text()
cmd:text('Train a multi-GPU Language Model using stacked LSTM on Google Billion Words dataset')
cmd:text('Example:')
cmd:text("th examples/multigpu-nce-rnnlm.lua --progress --earlystop 50 --device 2 --seqlen 20 --hiddensize '{200,200}' --batchsize 20 --startlr 1 --uniform 0.1 --cutoff 5 --schedule '{[5]=0.5,[6]=0.25,[7]=0.125,[8]=0.0625,[9]=0.03125,[10]=0.015625,[11]=0.0078125,[12]=0.00390625}'")
cmd:text("th examples/multigpu-nce-rnnlm.lua.lua --trainsize 400000 --validsize 40000 --cutoff 10 --batchsize 128 --seqlen 100 --hiddensize '{250,250}' --progress --device 2")
cmd:text("th scripts/evaluate-rnnlm.lua --xplogpath /data/save/rnnlm/ptb:atlas:1458081269:1.t7 --cuda")
cmd:text('Options:')
-- training
cmd:option('--startlr', 0.7, 'learning rate at t=0')
cmd:option('--minlr', 0.001, 'minimum learning rate')
cmd:option('--saturate', 300, 'epoch at which linear decayed LR will reach minlr')
cmd:option('--schedule', '', 'learning rate schedule. e.g. {[5] = 0.004, [6] = 0.001}')
cmd:option('--momentum', -1, 'momentum (requires an additional copy of all params)')
cmd:option('--maxnormout', -1, 'max l2-norm of each layer\'s output neuron weights')
cmd:option('--cutoff', 10, 'max l2-norm of concatenation of all gradParam tensors')
cmd:option('--device', 1, 'sets the device (GPU) to use')
cmd:option('--profile', false, 'profile updateOutput,updateGradInput and accGradParameters in Sequential')
cmd:option('--maxepoch', 1000, 'maximum number of epochs to run')
cmd:option('--earlystop', 50, 'maximum number of epochs to wait to find a better local minima for early-stopping')
cmd:option('--progress', false, 'print progress bar')
cmd:option('--silent', false, 'don\'t print anything to stdout')
cmd:option('--uniform', 0.1, 'initialize parameters using uniform distribution between -uniform and uniform. -1 means default initialization')
cmd:option('--k', 400, 'how many noise samples to use for NCE')
cmd:option('--continue', '', 'path to model for which training should be continued. Note that current options (except for device, cuda and tiny) will be ignored.')
cmd:option('--Z', -1, 'normalization constant for NCE module (-1 approximates it from first batch).')
cmd:option('--rownoise', false, 'sample k noise samples for each row for NCE module')
-- rnn layer
cmd:option('--seqlen', 50, 'sequence length : back-propagate through time (BPTT) for this many time-steps')
cmd:option('--inputsize', -1, 'size of lookup table embeddings. -1 defaults to hiddensize[1]')
cmd:option('--hiddensize', '{200,200}', 'number of hidden units used at output of each recurrent layer. When more than one is specified, RNN/LSTMs/GRUs are stacked')
cmd:option('--projsize', -1, 'size of the projection layer (number of hidden cell units for LSTMP)')
cmd:option('--dropout', 0, 'ancelossy dropout with this probability after each rnn layer. dropout <= 0 disables it.')
-- data
cmd:option('--batchsize', 32, 'number of examples per batch')
cmd:option('--trainsize', -1, 'number of train time-steps seen between each epoch')
cmd:option('--validsize', -1, 'number of valid time-steps used for early stopping and cross-validation')
cmd:option('--savepath', paths.concat(dl.SAVE_PATH, 'rnnlm'), 'path to directory where experiment log (includes model) will be saved')
cmd:option('--id', '', 'id string of this experiment (used to name output file) (defaults to a unique id)')
cmd:option('--tiny', false, 'use train_tiny.th7 training file')
cmd:option('--dontsave', false, 'dont save the model')
cmd:text()
local opt = cmd:parse(arg or {})
opt.hiddensize = loadstring(" return "..opt.hiddensize)()
opt.schedule = loadstring(" return "..opt.schedule)()
opt.inputsize = opt.inputsize == -1 and opt.hiddensize[1] or opt.inputsize
if not opt.silent then
table.print(opt)
end
opt.id = opt.id == '' and ('gbw' .. ':' .. dl.uniqueid()) or opt.id
opt.version = 1
cutorch.setDevice(opt.device)
local xplog, lm, criterion, targetmodule
if opt.continue ~= '' then
xplog = torch.load(opt.continue)
xplog.opt.cuda = true
xplog.opt.device = opt.device
xplog.opt.tiny = opt.tiny
opt = xplog.opt
lm = xplog.model.module
-- prevent re-casting bug
for i,lookup in ipairs(lm:findModules('nn.LookupTableMaskZero')) do
lookup.__input = nil
end
criterion = xplog.criterion
targetmodule = xplog.targetmodule
assert(opt)
end
--[[ data set ]]--
local trainset, validset, testset = dl.loadGBW({opt.batchsize,opt.batchsize,opt.batchsize}, opt.tiny and 'train_tiny.th7' or nil)
if not opt.silent then
print("Vocabulary size : "..#trainset.ivocab)
print("Train set split into "..opt.batchsize.." sequences of length "..trainset:size())
end
--[[ language model ]]--
if not lm then
assert(opt.maxnormout <= 0)
lm = nn.Sequential()
lm:add(nn.Convert())
-- input layer (i.e. word embedding space)
local concat = nn.Concat(3)
for device=1,2 do
local inputsize = device == 1 and torch.floor(opt.inputsize/2) or torch.ceil(opt.inputsize/2)
local lookup = nn.LookupTableMaskZero(#trainset.ivocab, inputsize)
lookup.maxnormout = -1 -- prevent weird maxnormout behaviour
concat:add(nn.GPU(lookup, device):cuda()) -- input is seqlen x batchsize
end
lm:add(nn.GPU(concat, 2):cuda())
if opt.dropout > 0 then
lm:add(nn.GPU(nn.Dropout(opt.dropout), 2):cuda())
end
-- rnn layers
local inputsize = opt.inputsize
for i,hiddensize in ipairs(opt.hiddensize) do
-- this is a faster version of nn.Sequencer(nn.FastLSTM(inpusize, hiddensize))
local rnn = opt.projsize < 1 and nn.SeqLSTM(inputsize, hiddensize)
or nn.SeqLSTMP(inputsize, opt.projsize, hiddensize) -- LSTM with a projection layer
rnn.maskzero = true
local device = i <= #opt.hiddensize/2 and 1 or 2
lm:add(nn.GPU(rnn, device):cuda())
if opt.dropout > 0 then
lm:add(nn.GPU(nn.Dropout(opt.dropout), device):cuda())
end
inputsize = hiddensize
end
lm:add(nn.GPU(nn.SplitTable(1), 3):cuda())
if opt.uniform > 0 then
for k,param in ipairs(lm:parameters()) do
assert(torch.type(param) == 'torch.CudaTensor')
cutorch.withDevice(param:getDevice(), function() param:uniform(-opt.uniform, opt.uniform) end)
end
end
-- output layer
local unigram = trainset.wordfreq:float()
ncemodule = nn.NCEModule(inputsize, #trainset.ivocab, opt.k, unigram, opt.Z)
ncemodule:reset() -- initializes bias to get approx. Z = 1
ncemodule.batchnoise = not opt.rownoise
-- distribute weight, gradWeight and momentum on devices 3 and 4
ncemodule:multicuda(3,4)
-- NCE requires {input, target} as inputs
lm = nn.Sequential()
:add(nn.ParallelTable()
:add(lm):add(nn.Identity()))
:add(nn.ZipTable()) -- {{x1,x2,...}, {t1,t2,...}} -> {{x1,t1},{x2,t2},...}
-- encapsulate stepmodule into a Sequencer
local masked = nn.MaskZero(ncemodule, 1):cuda()
lm:add(nn.GPU(nn.Sequencer(masked), 3, opt.device):cuda())
-- remember previous state between batches
lm:remember()
end
if opt.profile then
lm:profile()
end
if not opt.silent then
print"Language Model:"
print(lm)
end
if not (criterion and targetmodule) then
--[[ loss function ]]--
local crit = nn.MaskZeroCriterion(nn.NCECriterion(), 0)
-- target is also seqlen x batchsize.
targetmodule = nn.Sequential()
:add(nn.Convert())
:add(nn.SplitTable(1))
criterion = nn.SequencerCriterion(crit)
end
--[[ CUDA ]]--
lm:cuda()
criterion:cuda()
targetmodule:cuda()
--[[ experiment log ]]--
-- is saved to file every time a new validation minima is found
if not xplog then
xplog = {}
xplog.opt = opt -- save all hyper-parameters and such
xplog.dataset = 'GoogleBillionWords'
xplog.vocab = trainset.vocab
-- will only serialize params
xplog.model = nn.Serial(lm)
xplog.model:mediumSerial()
xplog.criterion = criterion
xplog.targetmodule = targetmodule
-- keep a log of NLL for each epoch
xplog.trainnceloss = {}
xplog.valnceloss = {}
-- will be used for early-stopping
xplog.minvalnceloss = 99999999
xplog.epoch = 0
paths.mkdir(opt.savepath)
end
local ntrial = 0
local epoch = xplog.epoch+1
opt.lr = opt.lr or opt.startlr
opt.trainsize = opt.trainsize == -1 and trainset:size() or opt.trainsize
opt.validsize = opt.validsize == -1 and validset:size() or opt.validsize
while opt.maxepoch <= 0 or epoch <= opt.maxepoch do
print("")
print("Epoch #"..epoch.." :")
-- 1. training
local a = torch.Timer()
lm:training()
local sumErr = 0
for i, inputs, targets in trainset:subiter(opt.seqlen, opt.trainsize) do
targets = targetmodule:forward(targets)
inputs = {inputs, targets}
-- forward
local outputs = lm:forward(inputs)
local err = criterion:forward(outputs, targets)
sumErr = sumErr + err
-- backward
local gradOutputs = criterion:backward(outputs, targets)
local a = torch.Timer()
lm:zeroGradParameters()
lm:backward(inputs, gradOutputs)
-- update
if opt.cutoff > 0 then
local norm = lm:gradParamClip(opt.cutoff) -- affects gradParams
opt.meanNorm = opt.meanNorm and (opt.meanNorm*0.9 + norm*0.1) or norm
end
lm:updateGradParameters(opt.momentum) -- affects gradParams
lm:updateParameters(opt.lr) -- affects params
lm:maxParamNorm(opt.maxnormout) -- affects params
if opt.progress then
xlua.progress(i, opt.trainsize)
end
if i % 2000 == 0 then
collectgarbage()
end
end
-- learning rate decay
if opt.schedule then
opt.lr = opt.schedule[epoch] or opt.lr
else
opt.lr = opt.lr + (opt.minlr - opt.startlr)/opt.saturate
end
opt.lr = math.max(opt.minlr, opt.lr)
if not opt.silent then
print("learning rate", opt.lr)
if opt.meanNorm then
print("mean gradParam norm", opt.meanNorm)
end
end
if cutorch then cutorch.synchronize() end
local speed = opt.trainsize*opt.batchsize/a:time().real
print(string.format("Speed : %f words/second; %f ms/word", speed, 1000/speed))
local nceloss = sumErr/opt.trainsize
print("Training error : "..nceloss)
xplog.trainnceloss[epoch] = nceloss
-- 2. cross-validation
lm:evaluate()
local sumErr = 0
for i, inputs, targets in validset:subiter(opt.seqlen, opt.validsize) do
targets = targetmodule:forward(targets)
local outputs = lm:forward{inputs, targets}
local err = criterion:forward(outputs, targets)
sumErr = sumErr + err
if opt.progress then
xlua.progress(i, opt.validsize)
end
end
local nceloss = sumErr/opt.validsize
print("Validation error : "..nceloss)
xplog.valnceloss[epoch] = nceloss
ntrial = ntrial + 1
-- early-stopping
if nceloss < xplog.minvalnceloss then
-- save best version of model
xplog.minvalnceloss = nceloss
xplog.epoch = epoch
local filename = paths.concat(opt.savepath, opt.id..'.t7')
if not opt.dontsave then
print("Found new minima. Saving to "..filename)
torch.save(filename, xplog)
end
ntrial = 0
elseif ntrial >= opt.earlystop then
print("No new minima found after "..ntrial.." epochs.")
print("Stopping experiment.")
print("Best model can be found in "..paths.concat(opt.savepath, opt.id..'.t7'))
os.exit()
end
collectgarbage()
epoch = epoch + 1
end
|
-- This file is automatically generated, do not edit!
-- Path of Building
--
-- Minion active skills
-- Skill data (c) Grinding Gear Games
--
local skills, mod, flag, skill = ...
skills["ChaosElementalCascadeSummoned"] = {
name = "Cascade",
hidden = true,
color = 3,
description = "Icicles emerge from the ground in a series of small bursts, each damaging enemies caught in the area.",
skillTypes = { [2] = true, [10] = true, [11] = true, [17] = true, [18] = true, [19] = true, [26] = true, [36] = true, [34] = true, [60] = true, },
castTime = 0.8,
baseFlags = {
spell = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_physical_damage",
"spell_maximum_base_physical_damage",
"upheaval_number_of_spikes",
"base_cast_speed_+%",
"skill_art_variation",
"base_physical_damage_%_to_convert_to_chaos",
"monster_penalty_against_minions_damage_+%_final_vs_player_minions",
"is_area_damage",
},
levels = {
[1] = { 9, 13, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 4, statInterpolation = { }, },
[2] = { 12, 18, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 7, statInterpolation = { }, },
[3] = { 14, 22, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 9, statInterpolation = { }, },
[4] = { 19, 28, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 12, statInterpolation = { }, },
[5] = { 26, 39, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 16, statInterpolation = { }, },
[6] = { 35, 52, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 20, statInterpolation = { }, },
[7] = { 55, 83, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 27, statInterpolation = { }, },
[8] = { 59, 89, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 28, statInterpolation = { }, },
[9] = { 63, 94, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 29, statInterpolation = { }, },
[10] = { 76, 114, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 32, statInterpolation = { }, },
[11] = { 96, 145, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 36, statInterpolation = { }, },
[12] = { 122, 182, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 40, statInterpolation = { }, },
[13] = { 161, 242, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 45, statInterpolation = { }, },
[14] = { 201, 301, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 49, statInterpolation = { }, },
[15] = { 212, 318, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 50, statInterpolation = { }, },
[16] = { 236, 354, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 52, statInterpolation = { }, },
[17] = { 292, 438, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 56, statInterpolation = { }, },
[18] = { 360, 539, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 60, statInterpolation = { }, },
[19] = { 441, 662, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 64, statInterpolation = { }, },
[20] = { 464, 696, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 65, statInterpolation = { }, },
[21] = { 488, 733, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 66, statInterpolation = { }, },
[22] = { 514, 770, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 67, statInterpolation = { }, },
[23] = { 540, 810, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 68, statInterpolation = { }, },
[24] = { 568, 852, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 69, statInterpolation = { }, },
[25] = { 597, 895, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 70, statInterpolation = { }, },
[26] = { 627, 941, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 71, statInterpolation = { }, },
[27] = { 659, 989, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 72, statInterpolation = { }, },
[28] = { 693, 1039, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 73, statInterpolation = { }, },
[29] = { 728, 1091, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 74, statInterpolation = { }, },
[30] = { 764, 1146, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 75, statInterpolation = { }, },
[31] = { 803, 1204, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 76, statInterpolation = { }, },
[32] = { 843, 1264, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 77, statInterpolation = { }, },
[33] = { 885, 1328, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 78, statInterpolation = { }, },
[34] = { 929, 1394, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 79, statInterpolation = { }, },
[35] = { 975, 1463, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 80, statInterpolation = { }, },
[36] = { 1024, 1535, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 81, statInterpolation = { }, },
[37] = { 1074, 1611, 6, 0, 3, 50, -25, damageEffectiveness = 0.6, cooldown = 3.5, levelRequirement = 82, statInterpolation = { }, },
},
}
skills["SandstormChaosElementalSummoned"] = {
name = "Chaos Aura",
hidden = true,
color = 4,
skillTypes = { [2] = true, [11] = true, [12] = true, },
castTime = 1,
baseFlags = {
spell = true,
duration = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"base_chaos_damage_to_deal_per_minute",
"base_skill_effect_duration",
"active_skill_area_of_effect_radius_+%_final",
"skill_art_variation",
"is_area_damage",
},
levels = {
[1] = { 872, 5000, 0, 2, cooldown = 8, levelRequirement = 3, statInterpolation = { }, },
[2] = { 1043, 5000, 0, 2, cooldown = 8, levelRequirement = 5, statInterpolation = { }, },
[3] = { 1317, 5000, 0, 2, cooldown = 8, levelRequirement = 8, statInterpolation = { }, },
[4] = { 1617, 5000, 0, 2, cooldown = 8, levelRequirement = 11, statInterpolation = { }, },
[5] = { 2058, 5000, 0, 2, cooldown = 8, levelRequirement = 15, statInterpolation = { }, },
[6] = { 2685, 5000, 0, 2, cooldown = 8, levelRequirement = 20, statInterpolation = { }, },
[7] = { 3251, 5000, 0, 2, cooldown = 8, levelRequirement = 24, statInterpolation = { }, },
[8] = { 3882, 5000, 0, 2, cooldown = 8, levelRequirement = 28, statInterpolation = { }, },
[9] = { 4051, 5000, 0, 2, cooldown = 8, levelRequirement = 29, statInterpolation = { }, },
[10] = { 4583, 5000, 0, 2, cooldown = 8, levelRequirement = 32, statInterpolation = { }, },
[11] = { 5362, 5000, 0, 2, cooldown = 8, levelRequirement = 36, statInterpolation = { }, },
[12] = { 6225, 5000, 0, 2, cooldown = 8, levelRequirement = 40, statInterpolation = { }, },
[13] = { 7434, 5000, 0, 2, cooldown = 8, levelRequirement = 45, statInterpolation = { }, },
[14] = { 8516, 5000, 0, 2, cooldown = 8, levelRequirement = 49, statInterpolation = { }, },
[15] = { 8804, 5000, 0, 2, cooldown = 8, levelRequirement = 50, statInterpolation = { }, },
[16] = { 9402, 5000, 0, 2, cooldown = 8, levelRequirement = 52, statInterpolation = { }, },
[17] = { 10687, 5000, 0, 2, cooldown = 8, levelRequirement = 56, statInterpolation = { }, },
[18] = { 12104, 5000, 0, 2, cooldown = 8, levelRequirement = 60, statInterpolation = { }, },
[19] = { 13664, 5000, 0, 2, cooldown = 8, levelRequirement = 64, statInterpolation = { }, },
[20] = { 14078, 5000, 0, 2, cooldown = 8, levelRequirement = 65, statInterpolation = { }, },
[21] = { 14501, 5000, 0, 2, cooldown = 8, levelRequirement = 66, statInterpolation = { }, },
[22] = { 14935, 5000, 0, 2, cooldown = 8, levelRequirement = 67, statInterpolation = { }, },
[23] = { 15379, 5000, 0, 2, cooldown = 8, levelRequirement = 68, statInterpolation = { }, },
[24] = { 15834, 5000, 0, 2, cooldown = 8, levelRequirement = 69, statInterpolation = { }, },
[25] = { 16299, 5000, 0, 2, cooldown = 8, levelRequirement = 70, statInterpolation = { }, },
[26] = { 16776, 5000, 0, 2, cooldown = 8, levelRequirement = 71, statInterpolation = { }, },
[27] = { 17264, 5000, 0, 2, cooldown = 8, levelRequirement = 72, statInterpolation = { }, },
[28] = { 17763, 5000, 0, 2, cooldown = 8, levelRequirement = 73, statInterpolation = { }, },
[29] = { 18275, 5000, 0, 2, cooldown = 8, levelRequirement = 74, statInterpolation = { }, },
[30] = { 18798, 5000, 0, 2, cooldown = 8, levelRequirement = 75, statInterpolation = { }, },
[31] = { 19333, 5000, 0, 2, cooldown = 8, levelRequirement = 76, statInterpolation = { }, },
[32] = { 19881, 5000, 0, 2, cooldown = 8, levelRequirement = 77, statInterpolation = { }, },
[33] = { 20442, 5000, 0, 2, cooldown = 8, levelRequirement = 78, statInterpolation = { }, },
[34] = { 21016, 5000, 0, 2, cooldown = 8, levelRequirement = 79, statInterpolation = { }, },
[35] = { 21604, 5000, 0, 2, cooldown = 8, levelRequirement = 80, statInterpolation = { }, },
[36] = { 22205, 5000, 0, 2, cooldown = 8, levelRequirement = 81, statInterpolation = { }, },
[37] = { 22820, 5000, 0, 2, cooldown = 8, levelRequirement = 82, statInterpolation = { }, },
},
}
skills["FireElementalFlameRedSummoned"] = {
name = "Immolate",
hidden = true,
color = 4,
description = "Summons a totem that fires a stream of flame at nearby enemies.",
skillTypes = { [2] = true, [3] = true, [10] = true, [12] = true, [17] = true, [19] = true, [30] = true, [33] = true, },
skillTotemId = 8,
castTime = 0.25,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_fire_damage",
"spell_maximum_base_fire_damage",
"skill_art_variation",
"active_skill_cast_speed_+%_final",
"spell_maximum_action_distance_+%",
"monster_penalty_against_minions_damage_+%_final_vs_player_minions",
"base_is_projectile",
"always_pierce",
},
levels = {
[1] = { 6, 8, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 3, statInterpolation = { }, },
[2] = { 7, 11, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 5, statInterpolation = { }, },
[3] = { 10, 14, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 8, statInterpolation = { }, },
[4] = { 14, 21, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 12, statInterpolation = { }, },
[5] = { 18, 27, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 15, statInterpolation = { }, },
[6] = { 24, 37, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 19, statInterpolation = { }, },
[7] = { 26, 39, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 20, statInterpolation = { }, },
[8] = { 28, 42, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 21, statInterpolation = { }, },
[9] = { 40, 61, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 26, statInterpolation = { }, },
[10] = { 53, 79, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 30, statInterpolation = { }, },
[11] = { 69, 103, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 34, statInterpolation = { }, },
[12] = { 88, 133, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 38, statInterpolation = { }, },
[13] = { 120, 180, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 43, statInterpolation = { }, },
[14] = { 135, 203, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 45, statInterpolation = { }, },
[15] = { 215, 323, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 53, statInterpolation = { }, },
[16] = { 285, 428, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 58, statInterpolation = { }, },
[17] = { 356, 534, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 62, statInterpolation = { }, },
[18] = { 376, 565, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 63, statInterpolation = { }, },
[19] = { 443, 665, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 66, statInterpolation = { }, },
[20] = { 468, 702, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 67, statInterpolation = { }, },
[21] = { 494, 741, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 68, statInterpolation = { }, },
[22] = { 522, 782, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 69, statInterpolation = { }, },
[23] = { 550, 825, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 70, statInterpolation = { }, },
[24] = { 581, 871, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 71, statInterpolation = { }, },
[25] = { 612, 919, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 72, statInterpolation = { }, },
[26] = { 646, 969, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 73, statInterpolation = { }, },
[27] = { 681, 1022, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 74, statInterpolation = { }, },
[28] = { 718, 1078, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 75, statInterpolation = { }, },
[29] = { 757, 1136, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 76, statInterpolation = { }, },
[30] = { 798, 1198, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 77, statInterpolation = { }, },
[31] = { 841, 1262, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 78, statInterpolation = { }, },
[32] = { 887, 1330, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 79, statInterpolation = { }, },
[33] = { 934, 1402, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 80, statInterpolation = { }, },
[34] = { 985, 1477, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 81, statInterpolation = { }, },
[35] = { 1037, 1556, 4, -89, -77, -25, damageEffectiveness = 0.2, levelRequirement = 82, statInterpolation = { }, },
},
}
skills["FireElementalMortarSummoned"] = {
name = "Magma Ball",
hidden = true,
color = 4,
description = "Generic monster mortar skill. Like Monster Projectile but has an impact effect.",
skillTypes = { [3] = true, [2] = true, [10] = true, [11] = true, [17] = true, [18] = true, [19] = true, [26] = true, [36] = true, },
castTime = 1,
baseFlags = {
spell = true,
projectile = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"monster_projectile_variation",
"projectile_spread_radius",
"spell_minimum_base_fire_damage",
"spell_maximum_base_fire_damage",
"spell_maximum_action_distance_+%",
"is_area_damage",
"base_is_projectile",
},
levels = {
[1] = { 3, 15, 152, 228, -33, critChance = 5, cooldown = 6, levelRequirement = 34, statInterpolation = { }, },
[2] = { 3, 15, 170, 254, -33, critChance = 5, cooldown = 6, levelRequirement = 36, statInterpolation = { }, },
[3] = { 3, 15, 188, 283, -33, critChance = 5, cooldown = 6, levelRequirement = 38, statInterpolation = { }, },
[4] = { 3, 15, 209, 314, -33, critChance = 5, cooldown = 6, levelRequirement = 40, statInterpolation = { }, },
[5] = { 3, 15, 232, 347, -33, critChance = 5, cooldown = 6, levelRequirement = 42, statInterpolation = { }, },
[6] = { 3, 15, 256, 384, -33, critChance = 5, cooldown = 6, levelRequirement = 44, statInterpolation = { }, },
[7] = { 3, 15, 283, 425, -33, critChance = 5, cooldown = 6, levelRequirement = 46, statInterpolation = { }, },
[8] = { 3, 15, 312, 468, -33, critChance = 5, cooldown = 6, levelRequirement = 48, statInterpolation = { }, },
[9] = { 3, 15, 344, 516, -33, critChance = 5, cooldown = 6, levelRequirement = 50, statInterpolation = { }, },
[10] = { 3, 15, 379, 568, -33, critChance = 5, cooldown = 6, levelRequirement = 52, statInterpolation = { }, },
[11] = { 3, 15, 416, 625, -33, critChance = 5, cooldown = 6, levelRequirement = 54, statInterpolation = { }, },
[12] = { 3, 15, 457, 686, -33, critChance = 5, cooldown = 6, levelRequirement = 56, statInterpolation = { }, },
[13] = { 3, 15, 502, 753, -33, critChance = 5, cooldown = 6, levelRequirement = 58, statInterpolation = { }, },
[14] = { 3, 15, 550, 826, -33, critChance = 5, cooldown = 6, levelRequirement = 60, statInterpolation = { }, },
[15] = { 3, 15, 603, 904, -33, critChance = 5, cooldown = 6, levelRequirement = 62, statInterpolation = { }, },
[16] = { 3, 15, 660, 990, -33, critChance = 5, cooldown = 6, levelRequirement = 64, statInterpolation = { }, },
[17] = { 3, 15, 722, 1083, -33, critChance = 5, cooldown = 6, levelRequirement = 66, statInterpolation = { }, },
[18] = { 3, 15, 789, 1184, -33, critChance = 5, cooldown = 6, levelRequirement = 68, statInterpolation = { }, },
[19] = { 3, 15, 825, 1237, -33, critChance = 5, cooldown = 6, levelRequirement = 69, statInterpolation = { }, },
[20] = { 3, 15, 862, 1293, -33, critChance = 5, cooldown = 6, levelRequirement = 70, statInterpolation = { }, },
[21] = { 3, 15, 941, 1412, -33, critChance = 5, cooldown = 6, levelRequirement = 72, statInterpolation = { }, },
[22] = { 3, 15, 1027, 1540, -33, critChance = 5, cooldown = 6, levelRequirement = 74, statInterpolation = { }, },
[23] = { 3, 15, 1120, 1680, -33, critChance = 5, cooldown = 6, levelRequirement = 76, statInterpolation = { }, },
[24] = { 3, 15, 1220, 1831, -33, critChance = 5, cooldown = 6, levelRequirement = 78, statInterpolation = { }, },
[25] = { 3, 15, 1329, 1994, -33, critChance = 5, cooldown = 6, levelRequirement = 80, statInterpolation = { }, },
[26] = { 3, 15, 1447, 2171, -33, critChance = 5, cooldown = 6, levelRequirement = 82, statInterpolation = { }, },
[27] = { 3, 15, 1575, 2363, -33, critChance = 5, cooldown = 6, levelRequirement = 84, statInterpolation = { }, },
[28] = { 3, 15, 1713, 2570, -33, critChance = 5, cooldown = 6, levelRequirement = 86, statInterpolation = { }, },
[29] = { 3, 15, 1863, 2794, -33, critChance = 5, cooldown = 6, levelRequirement = 88, statInterpolation = { }, },
[30] = { 3, 15, 2025, 3037, -33, critChance = 5, cooldown = 6, levelRequirement = 90, statInterpolation = { }, },
},
}
skills["FireElementalConeSummoned"] = {
name = "Flame Wave",
hidden = true,
color = 3,
skillTypes = { [2] = true, [10] = true, [11] = true, [17] = true, [18] = true, [19] = true, [26] = true, [36] = true, [33] = true, },
castTime = 0.935,
baseFlags = {
spell = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_fire_damage",
"spell_maximum_base_fire_damage",
"is_area_damage",
},
levels = {
[1] = { 106, 165, critChance = 10, cooldown = 2, levelRequirement = 34, statInterpolation = { }, },
[2] = { 117, 184, critChance = 10, cooldown = 2, levelRequirement = 36, statInterpolation = { }, },
[3] = { 131, 204, critChance = 10, cooldown = 2, levelRequirement = 38, statInterpolation = { }, },
[4] = { 145, 226, critChance = 10, cooldown = 2, levelRequirement = 40, statInterpolation = { }, },
[5] = { 160, 250, critChance = 10, cooldown = 2, levelRequirement = 42, statInterpolation = { }, },
[6] = { 177, 277, critChance = 10, cooldown = 2, levelRequirement = 44, statInterpolation = { }, },
[7] = { 196, 306, critChance = 10, cooldown = 2, levelRequirement = 46, statInterpolation = { }, },
[8] = { 216, 337, critChance = 10, cooldown = 2, levelRequirement = 48, statInterpolation = { }, },
[9] = { 237, 371, critChance = 10, cooldown = 2, levelRequirement = 50, statInterpolation = { }, },
[10] = { 261, 408, critChance = 10, cooldown = 2, levelRequirement = 52, statInterpolation = { }, },
[11] = { 287, 448, critChance = 10, cooldown = 2, levelRequirement = 54, statInterpolation = { }, },
[12] = { 315, 492, critChance = 10, cooldown = 2, levelRequirement = 56, statInterpolation = { }, },
[13] = { 346, 540, critChance = 10, cooldown = 2, levelRequirement = 58, statInterpolation = { }, },
[14] = { 379, 592, critChance = 10, cooldown = 2, levelRequirement = 60, statInterpolation = { }, },
[15] = { 415, 648, critChance = 10, cooldown = 2, levelRequirement = 62, statInterpolation = { }, },
[16] = { 454, 709, critChance = 10, cooldown = 2, levelRequirement = 64, statInterpolation = { }, },
[17] = { 496, 775, critChance = 10, cooldown = 2, levelRequirement = 66, statInterpolation = { }, },
[18] = { 542, 847, critChance = 10, cooldown = 2, levelRequirement = 68, statInterpolation = { }, },
[19] = { 566, 885, critChance = 10, cooldown = 2, levelRequirement = 69, statInterpolation = { }, },
[20] = { 592, 924, critChance = 10, cooldown = 2, levelRequirement = 70, statInterpolation = { }, },
[21] = { 645, 1008, critChance = 10, cooldown = 2, levelRequirement = 72, statInterpolation = { }, },
[22] = { 704, 1100, critChance = 10, cooldown = 2, levelRequirement = 74, statInterpolation = { }, },
[23] = { 767, 1198, critChance = 10, cooldown = 2, levelRequirement = 76, statInterpolation = { }, },
[24] = { 835, 1305, critChance = 10, cooldown = 2, levelRequirement = 78, statInterpolation = { }, },
[25] = { 909, 1421, critChance = 10, cooldown = 2, levelRequirement = 80, statInterpolation = { }, },
[26] = { 990, 1546, critChance = 10, cooldown = 2, levelRequirement = 82, statInterpolation = { }, },
[27] = { 1076, 1682, critChance = 10, cooldown = 2, levelRequirement = 84, statInterpolation = { }, },
[28] = { 1170, 1828, critChance = 10, cooldown = 2, levelRequirement = 86, statInterpolation = { }, },
[29] = { 1271, 1987, critChance = 10, cooldown = 2, levelRequirement = 88, statInterpolation = { }, },
[30] = { 1381, 2158, critChance = 10, cooldown = 2, levelRequirement = 90, statInterpolation = { }, },
},
}
skills["IceElementalIceCyclone"] = {
name = "Cyclone",
hidden = true,
color = 2,
description = "Damage enemies around you, then perform a spinning series of attacks as you travel to a target location.",
skillTypes = { [1] = true, [6] = true, [11] = true, [24] = true, [38] = true, },
weaponTypes = {
["None"] = true,
["One Handed Mace"] = true,
["Sceptre"] = true,
["Thrusting One Handed Sword"] = true,
["Two Handed Sword"] = true,
["Dagger"] = true,
["Staff"] = true,
["Two Handed Axe"] = true,
["Two Handed Mace"] = true,
["One Handed Axe"] = true,
["Claw"] = true,
["One Handed Sword"] = true,
},
castTime = 1,
baseFlags = {
attack = true,
area = true,
melee = true,
},
baseMods = {
skill("dpsMultiplier", 2),
skill("radiusIsWeaponRange", true),
},
qualityStats = {
},
stats = {
"skill_art_variation",
"cyclone_movement_speed_+%_final",
"cyclone_extra_distance",
"active_skill_damage_+%_final",
"base_skill_effect_duration",
"is_area_damage",
"cyclone_places_ground_ice",
},
levels = {
[1] = { 4, 75, 40, -20, 4000, cooldown = 6, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["IceElementalSpearSummoned"] = {
name = "Ice Spear",
hidden = true,
color = 3,
skillTypes = { [3] = true, [2] = true, [17] = true, [18] = true, },
castTime = 1,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_cold_damage",
"spell_maximum_base_cold_damage",
"monster_reverse_point_blank_damage_-%_at_minimum_range",
"base_is_projectile",
},
levels = {
[1] = { 10, 15, 25, cooldown = 4, levelRequirement = 3, statInterpolation = { }, },
[2] = { 12, 18, 25, cooldown = 4, levelRequirement = 5, statInterpolation = { }, },
[3] = { 16, 24, 25, cooldown = 4, levelRequirement = 8, statInterpolation = { }, },
[4] = { 21, 31, 25, cooldown = 4, levelRequirement = 11, statInterpolation = { }, },
[5] = { 28, 42, 25, cooldown = 4, levelRequirement = 15, statInterpolation = { }, },
[6] = { 40, 60, 25, cooldown = 4, levelRequirement = 20, statInterpolation = { }, },
[7] = { 51, 77, 25, cooldown = 4, levelRequirement = 24, statInterpolation = { }, },
[8] = { 65, 97, 25, cooldown = 4, levelRequirement = 28, statInterpolation = { }, },
[9] = { 69, 103, 25, cooldown = 4, levelRequirement = 29, statInterpolation = { }, },
[10] = { 81, 122, 25, cooldown = 4, levelRequirement = 32, statInterpolation = { }, },
[11] = { 101, 152, 25, cooldown = 4, levelRequirement = 36, statInterpolation = { }, },
[12] = { 125, 187, 25, cooldown = 4, levelRequirement = 40, statInterpolation = { }, },
[13] = { 161, 241, 25, cooldown = 4, levelRequirement = 45, statInterpolation = { }, },
[14] = { 196, 293, 25, cooldown = 4, levelRequirement = 49, statInterpolation = { }, },
[15] = { 205, 308, 25, cooldown = 4, levelRequirement = 50, statInterpolation = { }, },
[16] = { 226, 339, 25, cooldown = 4, levelRequirement = 52, statInterpolation = { }, },
[17] = { 273, 409, 25, cooldown = 4, levelRequirement = 56, statInterpolation = { }, },
[18] = { 328, 493, 25, cooldown = 4, levelRequirement = 60, statInterpolation = { }, },
[19] = { 394, 591, 25, cooldown = 4, levelRequirement = 64, statInterpolation = { }, },
[20] = { 412, 618, 25, cooldown = 4, levelRequirement = 65, statInterpolation = { }, },
[21] = { 431, 646, 25, cooldown = 4, levelRequirement = 66, statInterpolation = { }, },
[22] = { 450, 676, 25, cooldown = 4, levelRequirement = 67, statInterpolation = { }, },
[23] = { 471, 706, 25, cooldown = 4, levelRequirement = 68, statInterpolation = { }, },
[24] = { 492, 738, 25, cooldown = 4, levelRequirement = 69, statInterpolation = { }, },
[25] = { 514, 772, 25, cooldown = 4, levelRequirement = 70, statInterpolation = { }, },
[26] = { 537, 806, 25, cooldown = 4, levelRequirement = 71, statInterpolation = { }, },
[27] = { 562, 842, 25, cooldown = 4, levelRequirement = 72, statInterpolation = { }, },
[28] = { 587, 880, 25, cooldown = 4, levelRequirement = 73, statInterpolation = { }, },
[29] = { 613, 919, 25, cooldown = 4, levelRequirement = 74, statInterpolation = { }, },
[30] = { 640, 960, 25, cooldown = 4, levelRequirement = 75, statInterpolation = { }, },
[31] = { 668, 1002, 25, cooldown = 4, levelRequirement = 76, statInterpolation = { }, },
[32] = { 698, 1046, 25, cooldown = 4, levelRequirement = 77, statInterpolation = { }, },
[33] = { 728, 1092, 25, cooldown = 4, levelRequirement = 78, statInterpolation = { }, },
[34] = { 760, 1140, 25, cooldown = 4, levelRequirement = 79, statInterpolation = { }, },
[35] = { 793, 1190, 25, cooldown = 4, levelRequirement = 80, statInterpolation = { }, },
[36] = { 828, 1241, 25, cooldown = 4, levelRequirement = 81, statInterpolation = { }, },
[37] = { 864, 1295, 25, cooldown = 4, levelRequirement = 82, statInterpolation = { }, },
},
}
skills["LightningGolemArcSummoned"] = {
name = "Storm Orb",
hidden = true,
color = 3,
skillTypes = { [12] = true, [35] = true, [3] = true, [14] = true, [2] = true, },
castTime = 0.8,
baseFlags = {
spell = true,
projectile = true,
duration = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_lightning_damage",
"spell_maximum_base_lightning_damage",
"base_skill_effect_duration",
},
levels = {
[1] = { 1, 8, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 1, statInterpolation = { }, },
[2] = { 1, 9, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 2, statInterpolation = { }, },
[3] = { 1, 11, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 4, statInterpolation = { }, },
[4] = { 2, 14, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 7, statInterpolation = { }, },
[5] = { 2, 18, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 10, statInterpolation = { }, },
[6] = { 2, 22, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 13, statInterpolation = { }, },
[7] = { 3, 27, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 16, statInterpolation = { }, },
[8] = { 4, 32, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 19, statInterpolation = { }, },
[9] = { 4, 39, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 22, statInterpolation = { }, },
[10] = { 5, 46, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 25, statInterpolation = { }, },
[11] = { 6, 54, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 28, statInterpolation = { }, },
[12] = { 7, 62, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 31, statInterpolation = { }, },
[13] = { 8, 72, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 34, statInterpolation = { }, },
[14] = { 9, 80, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 36, statInterpolation = { }, },
[15] = { 10, 88, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 38, statInterpolation = { }, },
[16] = { 11, 96, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 40, statInterpolation = { }, },
[17] = { 12, 105, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 42, statInterpolation = { }, },
[18] = { 13, 115, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 44, statInterpolation = { }, },
[19] = { 14, 126, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 46, statInterpolation = { }, },
[20] = { 15, 137, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 48, statInterpolation = { }, },
[21] = { 17, 149, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 50, statInterpolation = { }, },
[22] = { 18, 162, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 52, statInterpolation = { }, },
[23] = { 20, 176, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 54, statInterpolation = { }, },
[24] = { 21, 191, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 56, statInterpolation = { }, },
[25] = { 23, 208, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 58, statInterpolation = { }, },
[26] = { 25, 225, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 60, statInterpolation = { }, },
[27] = { 27, 244, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 62, statInterpolation = { }, },
[28] = { 29, 264, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 64, statInterpolation = { }, },
[29] = { 32, 285, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 66, statInterpolation = { }, },
[30] = { 34, 308, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 68, statInterpolation = { }, },
[31] = { 36, 320, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 69, statInterpolation = { }, },
[32] = { 37, 333, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 70, statInterpolation = { }, },
[33] = { 40, 359, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 72, statInterpolation = { }, },
[34] = { 43, 387, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 74, statInterpolation = { }, },
[35] = { 46, 417, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 76, statInterpolation = { }, },
[36] = { 50, 449, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 78, statInterpolation = { }, },
[37] = { 54, 484, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 80, statInterpolation = { }, },
[38] = { 58, 521, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 82, statInterpolation = { }, },
[39] = { 62, 560, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 84, statInterpolation = { }, },
[40] = { 67, 602, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 86, statInterpolation = { }, },
[41] = { 72, 647, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 88, statInterpolation = { }, },
[42] = { 77, 695, 8000, damageEffectiveness = 0.6, cooldown = 8, critChance = 5, levelRequirement = 90, statInterpolation = { }, },
},
}
skills["MonsterProjectileSpellLightningGolemSummoned"] = {
name = "Lightning Projectile",
hidden = true,
color = 4,
skillTypes = { [2] = true, [3] = true, [36] = true, },
castTime = 1,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_lightning_damage",
"spell_maximum_base_lightning_damage",
"monster_projectile_variation",
"active_skill_cast_speed_+%_final",
"spell_maximum_action_distance_+%",
"base_is_projectile",
},
levels = {
[1] = { 2, 18, 11, -15, -40, critChance = 5, levelRequirement = 1, statInterpolation = { }, },
[2] = { 2, 21, 11, -15, -40, critChance = 5, levelRequirement = 2, statInterpolation = { }, },
[3] = { 3, 26, 11, -15, -40, critChance = 5, levelRequirement = 4, statInterpolation = { }, },
[4] = { 4, 35, 11, -15, -40, critChance = 5, levelRequirement = 7, statInterpolation = { }, },
[5] = { 5, 45, 11, -15, -40, critChance = 5, levelRequirement = 10, statInterpolation = { }, },
[6] = { 6, 58, 11, -15, -40, critChance = 5, levelRequirement = 13, statInterpolation = { }, },
[7] = { 8, 72, 11, -15, -40, critChance = 5, levelRequirement = 16, statInterpolation = { }, },
[8] = { 10, 89, 11, -15, -40, critChance = 5, levelRequirement = 19, statInterpolation = { }, },
[9] = { 12, 108, 11, -15, -40, critChance = 5, levelRequirement = 22, statInterpolation = { }, },
[10] = { 15, 131, 11, -15, -40, critChance = 5, levelRequirement = 25, statInterpolation = { }, },
[11] = { 17, 157, 11, -15, -40, critChance = 5, levelRequirement = 28, statInterpolation = { }, },
[12] = { 21, 187, 11, -15, -40, critChance = 5, levelRequirement = 31, statInterpolation = { }, },
[13] = { 25, 221, 11, -15, -40, critChance = 5, levelRequirement = 34, statInterpolation = { }, },
[14] = { 27, 247, 11, -15, -40, critChance = 5, levelRequirement = 36, statInterpolation = { }, },
[15] = { 31, 275, 11, -15, -40, critChance = 5, levelRequirement = 38, statInterpolation = { }, },
[16] = { 34, 306, 11, -15, -40, critChance = 5, levelRequirement = 40, statInterpolation = { }, },
[17] = { 38, 340, 11, -15, -40, critChance = 5, levelRequirement = 42, statInterpolation = { }, },
[18] = { 42, 378, 11, -15, -40, critChance = 5, levelRequirement = 44, statInterpolation = { }, },
[19] = { 46, 418, 11, -15, -40, critChance = 5, levelRequirement = 46, statInterpolation = { }, },
[20] = { 51, 463, 11, -15, -40, critChance = 5, levelRequirement = 48, statInterpolation = { }, },
[21] = { 57, 511, 11, -15, -40, critChance = 5, levelRequirement = 50, statInterpolation = { }, },
[22] = { 63, 565, 11, -15, -40, critChance = 5, levelRequirement = 52, statInterpolation = { }, },
[23] = { 69, 623, 11, -15, -40, critChance = 5, levelRequirement = 54, statInterpolation = { }, },
[24] = { 76, 686, 11, -15, -40, critChance = 5, levelRequirement = 56, statInterpolation = { }, },
[25] = { 84, 755, 11, -15, -40, critChance = 5, levelRequirement = 58, statInterpolation = { }, },
[26] = { 92, 830, 11, -15, -40, critChance = 5, levelRequirement = 60, statInterpolation = { }, },
[27] = { 101, 912, 11, -15, -40, critChance = 5, levelRequirement = 62, statInterpolation = { }, },
[28] = { 111, 1001, 11, -15, -40, critChance = 5, levelRequirement = 64, statInterpolation = { }, },
[29] = { 122, 1098, 11, -15, -40, critChance = 5, levelRequirement = 66, statInterpolation = { }, },
[30] = { 134, 1204, 11, -15, -40, critChance = 5, levelRequirement = 68, statInterpolation = { }, },
[31] = { 140, 1261, 11, -15, -40, critChance = 5, levelRequirement = 69, statInterpolation = { }, },
[32] = { 147, 1319, 11, -15, -40, critChance = 5, levelRequirement = 70, statInterpolation = { }, },
[33] = { 161, 1445, 11, -15, -40, critChance = 5, levelRequirement = 72, statInterpolation = { }, },
[34] = { 176, 1581, 11, -15, -40, critChance = 5, levelRequirement = 74, statInterpolation = { }, },
[35] = { 192, 1729, 11, -15, -40, critChance = 5, levelRequirement = 76, statInterpolation = { }, },
[36] = { 210, 1889, 11, -15, -40, critChance = 5, levelRequirement = 78, statInterpolation = { }, },
[37] = { 229, 2064, 11, -15, -40, critChance = 5, levelRequirement = 80, statInterpolation = { }, },
[38] = { 250, 2254, 11, -15, -40, critChance = 5, levelRequirement = 82, statInterpolation = { }, },
[39] = { 273, 2460, 11, -15, -40, critChance = 5, levelRequirement = 84, statInterpolation = { }, },
[40] = { 298, 2683, 11, -15, -40, critChance = 5, levelRequirement = 86, statInterpolation = { }, },
[41] = { 325, 2926, 11, -15, -40, critChance = 5, levelRequirement = 88, statInterpolation = { }, },
[42] = { 354, 3189, 11, -15, -40, critChance = 5, levelRequirement = 90, statInterpolation = { }, },
},
}
skills["LightningGolemWrath"] = {
name = "Wrath",
hidden = true,
color = 3,
skillTypes = { [2] = true, [11] = true, [5] = true, [16] = true, [44] = true, [35] = true, [12] = true, },
castTime = 0.8,
statMap = {
["attack_minimum_added_lightning_damage"] = {
mod("LightningMin", "BASE", nil, 0, KeywordFlag.Attack, { type = "GlobalEffect", effectType = "Aura" }),
},
["attack_maximum_added_lightning_damage"] = {
mod("LightningMax", "BASE", nil, 0, KeywordFlag.Attack, { type = "GlobalEffect", effectType = "Aura" }),
},
["spell_minimum_added_lightning_damage"] = {
mod("LightningMin", "BASE", nil, 0, KeywordFlag.Spell, { type = "GlobalEffect", effectType = "Aura" }),
},
["spell_maximum_added_lightning_damage"] = {
mod("LightningMax", "BASE", nil, 0, KeywordFlag.Spell, { type = "GlobalEffect", effectType = "Aura" }),
},
},
baseFlags = {
spell = true,
aura = true,
area = true,
duration = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"attack_minimum_added_lightning_damage",
"attack_maximum_added_lightning_damage",
"base_skill_effect_duration",
"spell_minimum_added_lightning_damage",
"spell_maximum_added_lightning_damage",
"base_deal_no_damage",
},
levels = {
[1] = { 1, 1, 4000, 1, 1, cooldown = 12, levelRequirement = 1, statInterpolation = { }, },
[2] = { 1, 2, 4000, 1, 1, cooldown = 12, levelRequirement = 8, statInterpolation = { }, },
[3] = { 1, 4, 4000, 1, 2, cooldown = 12, levelRequirement = 16, statInterpolation = { }, },
[4] = { 1, 6, 4000, 1, 3, cooldown = 12, levelRequirement = 24, statInterpolation = { }, },
[5] = { 1, 9, 4000, 1, 5, cooldown = 12, levelRequirement = 34, statInterpolation = { }, },
[6] = { 1, 10, 4000, 1, 6, cooldown = 12, levelRequirement = 36, statInterpolation = { }, },
[7] = { 1, 10, 4000, 1, 6, cooldown = 12, levelRequirement = 38, statInterpolation = { }, },
[8] = { 1, 11, 4000, 1, 7, cooldown = 12, levelRequirement = 40, statInterpolation = { }, },
[9] = { 1, 12, 4000, 1, 7, cooldown = 12, levelRequirement = 42, statInterpolation = { }, },
[10] = { 1, 13, 4000, 1, 8, cooldown = 12, levelRequirement = 44, statInterpolation = { }, },
[11] = { 2, 14, 4000, 1, 9, cooldown = 12, levelRequirement = 46, statInterpolation = { }, },
[12] = { 2, 15, 4000, 1, 9, cooldown = 12, levelRequirement = 48, statInterpolation = { }, },
[13] = { 2, 17, 4000, 1, 10, cooldown = 12, levelRequirement = 50, statInterpolation = { }, },
[14] = { 2, 18, 4000, 1, 11, cooldown = 12, levelRequirement = 52, statInterpolation = { }, },
[15] = { 2, 19, 4000, 1, 12, cooldown = 12, levelRequirement = 54, statInterpolation = { }, },
[16] = { 2, 21, 4000, 1, 12, cooldown = 12, levelRequirement = 56, statInterpolation = { }, },
[17] = { 2, 22, 4000, 1, 13, cooldown = 12, levelRequirement = 58, statInterpolation = { }, },
[18] = { 3, 24, 4000, 2, 14, cooldown = 12, levelRequirement = 60, statInterpolation = { }, },
[19] = { 3, 25, 4000, 2, 15, cooldown = 12, levelRequirement = 62, statInterpolation = { }, },
[20] = { 3, 27, 4000, 2, 16, cooldown = 12, levelRequirement = 64, statInterpolation = { }, },
[21] = { 3, 29, 4000, 2, 17, cooldown = 12, levelRequirement = 66, statInterpolation = { }, },
[22] = { 3, 31, 4000, 2, 19, cooldown = 12, levelRequirement = 68, statInterpolation = { }, },
[23] = { 4, 32, 4000, 2, 19, cooldown = 12, levelRequirement = 69, statInterpolation = { }, },
[24] = { 4, 33, 4000, 2, 20, cooldown = 12, levelRequirement = 70, statInterpolation = { }, },
[25] = { 4, 35, 4000, 2, 21, cooldown = 12, levelRequirement = 72, statInterpolation = { }, },
[26] = { 4, 37, 4000, 2, 22, cooldown = 12, levelRequirement = 74, statInterpolation = { }, },
[27] = { 4, 40, 4000, 3, 24, cooldown = 12, levelRequirement = 76, statInterpolation = { }, },
[28] = { 5, 42, 4000, 3, 25, cooldown = 12, levelRequirement = 78, statInterpolation = { }, },
[29] = { 5, 45, 4000, 3, 27, cooldown = 12, levelRequirement = 80, statInterpolation = { }, },
[30] = { 5, 48, 4000, 3, 29, cooldown = 12, levelRequirement = 82, statInterpolation = { }, },
[31] = { 6, 51, 4000, 3, 31, cooldown = 12, levelRequirement = 84, statInterpolation = { }, },
[32] = { 6, 54, 4000, 4, 33, cooldown = 12, levelRequirement = 86, statInterpolation = { }, },
[33] = { 6, 58, 4000, 4, 35, cooldown = 12, levelRequirement = 88, statInterpolation = { }, },
[34] = { 7, 61, 4000, 4, 37, cooldown = 12, levelRequirement = 90, statInterpolation = { }, },
},
}
skills["PlayerRagingSpiritMeleeAttack"] = {
name = "Melee Attack",
hidden = true,
color = 4,
description = "Strike your foes down with a powerful blow.",
skillTypes = { [1] = true, [48] = true, [6] = true, [3] = true, [25] = true, [28] = true, [24] = true, },
castTime = 1,
baseFlags = {
attack = true,
melee = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"active_skill_damage_+%_final",
},
levels = {
[1] = { 76, levelRequirement = 4, statInterpolation = { }, },
[2] = { 75, levelRequirement = 6, statInterpolation = { }, },
[3] = { 74, levelRequirement = 9, statInterpolation = { }, },
[4] = { 73, levelRequirement = 12, statInterpolation = { }, },
[5] = { 72, levelRequirement = 15, statInterpolation = { }, },
[6] = { 71, levelRequirement = 19, statInterpolation = { }, },
[7] = { 70, levelRequirement = 23, statInterpolation = { }, },
[8] = { 69, levelRequirement = 28, statInterpolation = { }, },
[9] = { 68, levelRequirement = 33, statInterpolation = { }, },
[10] = { 67, levelRequirement = 39, statInterpolation = { }, },
[11] = { 66, levelRequirement = 43, statInterpolation = { }, },
[12] = { 65, levelRequirement = 46, statInterpolation = { }, },
[13] = { 64, levelRequirement = 49, statInterpolation = { }, },
[14] = { 63, levelRequirement = 52, statInterpolation = { }, },
[15] = { 62, levelRequirement = 55, statInterpolation = { }, },
[16] = { 61, levelRequirement = 58, statInterpolation = { }, },
[17] = { 60, levelRequirement = 61, statInterpolation = { }, },
[18] = { 59, levelRequirement = 64, statInterpolation = { }, },
[19] = { 58, levelRequirement = 66, statInterpolation = { }, },
[20] = { 57, levelRequirement = 68, statInterpolation = { }, },
[21] = { 56, levelRequirement = 70, statInterpolation = { }, },
[22] = { 55, levelRequirement = 72, statInterpolation = { }, },
[23] = { 54, levelRequirement = 74, statInterpolation = { }, },
[24] = { 53, levelRequirement = 76, statInterpolation = { }, },
[25] = { 52, levelRequirement = 78, statInterpolation = { }, },
[26] = { 51, levelRequirement = 80, statInterpolation = { }, },
[27] = { 50, levelRequirement = 82, statInterpolation = { }, },
[28] = { 49, levelRequirement = 84, statInterpolation = { }, },
[29] = { 48, levelRequirement = 86, statInterpolation = { }, },
[30] = { 47, levelRequirement = 88, statInterpolation = { }, },
},
}
skills["RagingSpiritMeleeAttack"] = {
name = "Melee Attack",
hidden = true,
color = 4,
description = "Strike your foes down with a powerful blow.",
skillTypes = { [1] = true, [48] = true, [6] = true, [3] = true, [25] = true, [28] = true, [24] = true, },
castTime = 1,
baseFlags = {
attack = true,
melee = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"active_skill_damage_+%_final",
},
levels = {
[1] = { 76, levelRequirement = 4, statInterpolation = { }, },
[2] = { 71, levelRequirement = 6, statInterpolation = { }, },
[3] = { 66, levelRequirement = 9, statInterpolation = { }, },
[4] = { 61, levelRequirement = 12, statInterpolation = { }, },
[5] = { 56, levelRequirement = 15, statInterpolation = { }, },
[6] = { 52, levelRequirement = 19, statInterpolation = { }, },
[7] = { 47, levelRequirement = 23, statInterpolation = { }, },
[8] = { 42, levelRequirement = 28, statInterpolation = { }, },
[9] = { 37, levelRequirement = 33, statInterpolation = { }, },
[10] = { 32, levelRequirement = 39, statInterpolation = { }, },
[11] = { 28, levelRequirement = 43, statInterpolation = { }, },
[12] = { 23, levelRequirement = 46, statInterpolation = { }, },
[13] = { 18, levelRequirement = 49, statInterpolation = { }, },
[14] = { 12, levelRequirement = 52, statInterpolation = { }, },
[15] = { 10, levelRequirement = 55, statInterpolation = { }, },
[16] = { 7, levelRequirement = 58, statInterpolation = { }, },
[17] = { 5, levelRequirement = 61, statInterpolation = { }, },
[18] = { 2, levelRequirement = 64, statInterpolation = { }, },
[19] = { 0, levelRequirement = 66, statInterpolation = { }, },
[20] = { -2, levelRequirement = 68, statInterpolation = { }, },
[21] = { -4, levelRequirement = 70, statInterpolation = { }, },
[22] = { -7, levelRequirement = 72, statInterpolation = { }, },
[23] = { -10, levelRequirement = 74, statInterpolation = { }, },
[24] = { -10, levelRequirement = 76, statInterpolation = { }, },
[25] = { -10, levelRequirement = 78, statInterpolation = { }, },
[26] = { -10, levelRequirement = 80, statInterpolation = { }, },
[27] = { -10, levelRequirement = 82, statInterpolation = { }, },
[28] = { -10, levelRequirement = 84, statInterpolation = { }, },
[29] = { -10, levelRequirement = 86, statInterpolation = { }, },
[30] = { -10, levelRequirement = 88, statInterpolation = { }, },
},
}
skills["SpectralSkullShieldCharge"] = {
name = "Charge",
hidden = true,
color = 4,
description = "Charges at an enemy, bashing it with the character's shield and striking it. This knocks it back and stuns it. Enemies in the way are pushed to the side. Damage and stun are proportional to distance travelled.",
skillTypes = { [1] = true, [7] = true, [13] = true, [24] = true, [25] = true, [38] = true, },
weaponTypes = {
["None"] = true,
["Claw"] = true,
["One Handed Mace"] = true,
["Sceptre"] = true,
["Thrusting One Handed Sword"] = true,
["One Handed Axe"] = true,
["Dagger"] = true,
["One Handed Sword"] = true,
},
castTime = 1,
baseFlags = {
attack = true,
melee = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"shield_charge_stun_duration_+%_maximum",
"base_movement_velocity_+%",
"shield_charge_damage_+%_maximum",
"active_skill_damage_+%_final",
"ignores_proximity_shield",
},
levels = {
[1] = { 200, 500, 300, -50, cooldown = 5, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["SkeletonProjectileCold"] = {
name = "Cold Projectile",
hidden = true,
color = 4,
skillTypes = { [2] = true, [10] = true, [26] = true, [3] = true, },
castTime = 1.95,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_cold_damage",
"spell_maximum_base_cold_damage",
"base_is_projectile",
"spell_maximum_action_distance_+%",
},
levels = {
[1] = { 3, 5, 1, -60, critChance = 5, levelRequirement = 4, manaCost = 5, statInterpolation = { }, },
[2] = { 4, 6, 1, -60, critChance = 5, levelRequirement = 7, manaCost = 5, statInterpolation = { }, },
[3] = { 6, 8, 1, -60, critChance = 5, levelRequirement = 10, manaCost = 5, statInterpolation = { }, },
[4] = { 8, 13, 1, -60, critChance = 5, levelRequirement = 15, manaCost = 5, statInterpolation = { }, },
[5] = { 11, 17, 1, -60, critChance = 5, levelRequirement = 19, manaCost = 4, statInterpolation = { }, },
[6] = { 12, 18, 1, -60, critChance = 5, levelRequirement = 20, manaCost = 4, statInterpolation = { }, },
[7] = { 17, 26, 1, -60, critChance = 5, levelRequirement = 25, manaCost = 4, statInterpolation = { }, },
[8] = { 21, 32, 1, -60, critChance = 5, levelRequirement = 28, manaCost = 4, statInterpolation = { }, },
[9] = { 22, 34, 1, -60, critChance = 5, levelRequirement = 29, manaCost = 4, statInterpolation = { }, },
[10] = { 24, 36, 1, -60, critChance = 5, levelRequirement = 30, manaCost = 4, statInterpolation = { }, },
[11] = { 29, 43, 1, -60, critChance = 5, levelRequirement = 33, manaCost = 4, statInterpolation = { }, },
[12] = { 31, 46, 1, -60, critChance = 5, levelRequirement = 34, manaCost = 4, statInterpolation = { }, },
[13] = { 37, 55, 1, -60, critChance = 5, levelRequirement = 37, manaCost = 4, statInterpolation = { }, },
[14] = { 42, 62, 1, -60, critChance = 5, levelRequirement = 39, manaCost = 4, statInterpolation = { }, },
[15] = { 53, 79, 1, -60, critChance = 5, levelRequirement = 43, manaCost = 4, statInterpolation = { }, },
[16] = { 56, 84, 1, -60, critChance = 5, levelRequirement = 44, manaCost = 4, statInterpolation = { }, },
[17] = { 66, 99, 1, -60, critChance = 5, levelRequirement = 47, manaCost = 4, statInterpolation = { }, },
[18] = { 70, 105, 1, -60, critChance = 5, levelRequirement = 48, manaCost = 4, statInterpolation = { }, },
[19] = { 82, 124, 1, -60, critChance = 5, levelRequirement = 51, manaCost = 4, statInterpolation = { }, },
[20] = { 121, 181, 1, -60, critChance = 5, levelRequirement = 58, manaCost = 4, statInterpolation = { }, },
[21] = { 141, 212, 1, -60, critChance = 5, levelRequirement = 61, manaCost = 4, statInterpolation = { }, },
[22] = { 149, 223, 1, -60, critChance = 5, levelRequirement = 62, manaCost = 4, statInterpolation = { }, },
[23] = { 157, 236, 1, -60, critChance = 5, levelRequirement = 63, manaCost = 4, statInterpolation = { }, },
[24] = { 165, 248, 1, -60, critChance = 5, levelRequirement = 64, manaCost = 4, statInterpolation = { }, },
[25] = { 174, 261, 1, -60, critChance = 5, levelRequirement = 65, manaCost = 4, statInterpolation = { }, },
[26] = { 184, 275, 1, -60, critChance = 5, levelRequirement = 66, manaCost = 4, statInterpolation = { }, },
[27] = { 193, 290, 1, -60, critChance = 5, levelRequirement = 67, manaCost = 4, statInterpolation = { }, },
[28] = { 687, 1071, 1, -60, critChance = 5, levelRequirement = 68, manaCost = 4, statInterpolation = { }, },
[29] = { 723, 1128, 1, -60, critChance = 5, levelRequirement = 69, manaCost = 4, statInterpolation = { }, },
[30] = { 761, 1187, 1, -60, critChance = 5, levelRequirement = 70, manaCost = 4, statInterpolation = { }, },
[31] = { 801, 1249, 1, -60, critChance = 5, levelRequirement = 71, manaCost = 4, statInterpolation = { }, },
[32] = { 843, 1315, 1, -60, critChance = 5, levelRequirement = 72, manaCost = 4, statInterpolation = { }, },
[33] = { 887, 1383, 1, -60, critChance = 5, levelRequirement = 73, manaCost = 4, statInterpolation = { }, },
[34] = { 933, 1455, 1, -60, critChance = 5, levelRequirement = 74, manaCost = 4, statInterpolation = { }, },
[35] = { 981, 1530, 1, -60, critChance = 5, levelRequirement = 75, manaCost = 4, statInterpolation = { }, },
[36] = { 1032, 1609, 1, -60, critChance = 5, levelRequirement = 76, manaCost = 4, statInterpolation = { }, },
[37] = { 1085, 1692, 1, -60, critChance = 5, levelRequirement = 77, manaCost = 4, statInterpolation = { }, },
[38] = { 1141, 1779, 1, -60, critChance = 5, levelRequirement = 78, manaCost = 4, statInterpolation = { }, },
[39] = { 1200, 1870, 1, -60, critChance = 5, levelRequirement = 79, manaCost = 4, statInterpolation = { }, },
[40] = { 1261, 1966, 1, -60, critChance = 5, levelRequirement = 80, manaCost = 4, statInterpolation = { }, },
[41] = { 1325, 2066, 1, -60, critChance = 5, levelRequirement = 81, manaCost = 4, statInterpolation = { }, },
[42] = { 1393, 2171, 1, -60, critChance = 5, levelRequirement = 82, manaCost = 4, statInterpolation = { }, },
},
}
skills["SkeletonProjectileFire"] = {
name = "Fire Projectile",
hidden = true,
color = 4,
skillTypes = { [2] = true, [10] = true, [26] = true, [3] = true, },
castTime = 1.95,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_fire_damage",
"spell_maximum_base_fire_damage",
"base_is_projectile",
"spell_maximum_action_distance_+%",
},
levels = {
[1] = { 4, 6, 1, -60, critChance = 5, levelRequirement = 4, manaCost = 5, statInterpolation = { }, },
[2] = { 5, 8, 1, -60, critChance = 5, levelRequirement = 7, manaCost = 5, statInterpolation = { }, },
[3] = { 7, 10, 1, -60, critChance = 5, levelRequirement = 10, manaCost = 5, statInterpolation = { }, },
[4] = { 10, 15, 1, -60, critChance = 5, levelRequirement = 15, manaCost = 5, statInterpolation = { }, },
[5] = { 14, 21, 1, -60, critChance = 5, levelRequirement = 19, manaCost = 4, statInterpolation = { }, },
[6] = { 15, 22, 1, -60, critChance = 5, levelRequirement = 20, manaCost = 4, statInterpolation = { }, },
[7] = { 21, 32, 1, -60, critChance = 5, levelRequirement = 25, manaCost = 4, statInterpolation = { }, },
[8] = { 26, 39, 1, -60, critChance = 5, levelRequirement = 28, manaCost = 4, statInterpolation = { }, },
[9] = { 27, 41, 1, -60, critChance = 5, levelRequirement = 29, manaCost = 4, statInterpolation = { }, },
[10] = { 29, 44, 1, -60, critChance = 5, levelRequirement = 30, manaCost = 4, statInterpolation = { }, },
[11] = { 35, 53, 1, -60, critChance = 5, levelRequirement = 33, manaCost = 4, statInterpolation = { }, },
[12] = { 38, 56, 1, -60, critChance = 5, levelRequirement = 34, manaCost = 4, statInterpolation = { }, },
[13] = { 45, 68, 1, -60, critChance = 5, levelRequirement = 37, manaCost = 4, statInterpolation = { }, },
[14] = { 51, 76, 1, -60, critChance = 5, levelRequirement = 39, manaCost = 4, statInterpolation = { }, },
[15] = { 64, 96, 1, -60, critChance = 5, levelRequirement = 43, manaCost = 4, statInterpolation = { }, },
[16] = { 68, 102, 1, -60, critChance = 5, levelRequirement = 44, manaCost = 4, statInterpolation = { }, },
[17] = { 81, 121, 1, -60, critChance = 5, levelRequirement = 47, manaCost = 4, statInterpolation = { }, },
[18] = { 85, 128, 1, -60, critChance = 5, levelRequirement = 48, manaCost = 4, statInterpolation = { }, },
[19] = { 101, 151, 1, -60, critChance = 5, levelRequirement = 51, manaCost = 4, statInterpolation = { }, },
[20] = { 147, 221, 1, -60, critChance = 5, levelRequirement = 58, manaCost = 4, statInterpolation = { }, },
[21] = { 173, 259, 1, -60, critChance = 5, levelRequirement = 61, manaCost = 4, statInterpolation = { }, },
[22] = { 182, 273, 1, -60, critChance = 5, levelRequirement = 62, manaCost = 4, statInterpolation = { }, },
[23] = { 192, 288, 1, -60, critChance = 5, levelRequirement = 63, manaCost = 4, statInterpolation = { }, },
[24] = { 202, 303, 1, -60, critChance = 5, levelRequirement = 64, manaCost = 4, statInterpolation = { }, },
[25] = { 213, 320, 1, -60, critChance = 5, levelRequirement = 65, manaCost = 4, statInterpolation = { }, },
[26] = { 224, 337, 1, -60, critChance = 5, levelRequirement = 66, manaCost = 4, statInterpolation = { }, },
[27] = { 236, 354, 1, -60, critChance = 5, levelRequirement = 67, manaCost = 4, statInterpolation = { }, },
[28] = { 840, 1309, 1, -60, critChance = 5, levelRequirement = 68, manaCost = 4, statInterpolation = { }, },
[29] = { 884, 1378, 1, -60, critChance = 5, levelRequirement = 69, manaCost = 4, statInterpolation = { }, },
[30] = { 930, 1451, 1, -60, critChance = 5, levelRequirement = 70, manaCost = 4, statInterpolation = { }, },
[31] = { 979, 1527, 1, -60, critChance = 5, levelRequirement = 71, manaCost = 4, statInterpolation = { }, },
[32] = { 1030, 1607, 1, -60, critChance = 5, levelRequirement = 72, manaCost = 4, statInterpolation = { }, },
[33] = { 1084, 1690, 1, -60, critChance = 5, levelRequirement = 73, manaCost = 4, statInterpolation = { }, },
[34] = { 1140, 1778, 1, -60, critChance = 5, levelRequirement = 74, manaCost = 4, statInterpolation = { }, },
[35] = { 1200, 1870, 1, -60, critChance = 5, levelRequirement = 75, manaCost = 4, statInterpolation = { }, },
[36] = { 1262, 1967, 1, -60, critChance = 5, levelRequirement = 76, manaCost = 4, statInterpolation = { }, },
[37] = { 1327, 2068, 1, -60, critChance = 5, levelRequirement = 77, manaCost = 4, statInterpolation = { }, },
[38] = { 1395, 2175, 1, -60, critChance = 5, levelRequirement = 78, manaCost = 4, statInterpolation = { }, },
[39] = { 1466, 2286, 1, -60, critChance = 5, levelRequirement = 79, manaCost = 4, statInterpolation = { }, },
[40] = { 1541, 2403, 1, -60, critChance = 5, levelRequirement = 80, manaCost = 4, statInterpolation = { }, },
[41] = { 1620, 2525, 1, -60, critChance = 5, levelRequirement = 81, manaCost = 4, statInterpolation = { }, },
[42] = { 1702, 2654, 1, -60, critChance = 5, levelRequirement = 82, manaCost = 4, statInterpolation = { }, },
},
}
skills["SkeletonProjectileLightning"] = {
name = "Lightning Projectile",
hidden = true,
color = 4,
skillTypes = { [2] = true, [10] = true, [26] = true, [3] = true, },
castTime = 1.95,
baseFlags = {
spell = true,
projectile = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"spell_minimum_base_lightning_damage",
"spell_maximum_base_lightning_damage",
"base_is_projectile",
"spell_maximum_action_distance_+%",
},
levels = {
[1] = { 3, 8, 1, -60, critChance = 5, levelRequirement = 4, manaCost = 5, statInterpolation = { }, },
[2] = { 4, 11, 1, -60, critChance = 5, levelRequirement = 7, manaCost = 5, statInterpolation = { }, },
[3] = { 5, 14, 1, -60, critChance = 5, levelRequirement = 10, manaCost = 5, statInterpolation = { }, },
[4] = { 7, 22, 1, -60, critChance = 5, levelRequirement = 15, manaCost = 5, statInterpolation = { }, },
[5] = { 10, 29, 1, -60, critChance = 5, levelRequirement = 19, manaCost = 4, statInterpolation = { }, },
[6] = { 10, 31, 1, -60, critChance = 5, levelRequirement = 20, manaCost = 4, statInterpolation = { }, },
[7] = { 15, 45, 1, -60, critChance = 5, levelRequirement = 25, manaCost = 4, statInterpolation = { }, },
[8] = { 18, 54, 1, -60, critChance = 5, levelRequirement = 28, manaCost = 4, statInterpolation = { }, },
[9] = { 19, 58, 1, -60, critChance = 5, levelRequirement = 29, manaCost = 4, statInterpolation = { }, },
[10] = { 21, 62, 1, -60, critChance = 5, levelRequirement = 30, manaCost = 4, statInterpolation = { }, },
[11] = { 22, 66, 1, -60, critChance = 5, levelRequirement = 31, manaCost = 4, statInterpolation = { }, },
[12] = { 26, 79, 1, -60, critChance = 5, levelRequirement = 34, manaCost = 4, statInterpolation = { }, },
[13] = { 32, 95, 1, -60, critChance = 5, levelRequirement = 37, manaCost = 4, statInterpolation = { }, },
[14] = { 36, 107, 1, -60, critChance = 5, levelRequirement = 39, manaCost = 4, statInterpolation = { }, },
[15] = { 45, 136, 1, -60, critChance = 5, levelRequirement = 43, manaCost = 4, statInterpolation = { }, },
[16] = { 48, 144, 1, -60, critChance = 5, levelRequirement = 44, manaCost = 4, statInterpolation = { }, },
[17] = { 57, 170, 1, -60, critChance = 5, levelRequirement = 47, manaCost = 4, statInterpolation = { }, },
[18] = { 60, 180, 1, -60, critChance = 5, levelRequirement = 48, manaCost = 4, statInterpolation = { }, },
[19] = { 71, 213, 1, -60, critChance = 5, levelRequirement = 51, manaCost = 4, statInterpolation = { }, },
[20] = { 75, 225, 1, -60, critChance = 5, levelRequirement = 52, manaCost = 4, statInterpolation = { }, },
[21] = { 104, 311, 1, -60, critChance = 5, levelRequirement = 58, manaCost = 4, statInterpolation = { }, },
[22] = { 128, 384, 1, -60, critChance = 5, levelRequirement = 62, manaCost = 4, statInterpolation = { }, },
[23] = { 135, 405, 1, -60, critChance = 5, levelRequirement = 63, manaCost = 4, statInterpolation = { }, },
[24] = { 142, 427, 1, -60, critChance = 5, levelRequirement = 64, manaCost = 4, statInterpolation = { }, },
[25] = { 150, 449, 1, -60, critChance = 5, levelRequirement = 65, manaCost = 4, statInterpolation = { }, },
[26] = { 158, 473, 1, -60, critChance = 5, levelRequirement = 66, manaCost = 4, statInterpolation = { }, },
[27] = { 166, 498, 1, -60, critChance = 5, levelRequirement = 67, manaCost = 4, statInterpolation = { }, },
[28] = { 409, 1221, 1, -60, critChance = 5, levelRequirement = 68, manaCost = 4, statInterpolation = { }, },
[29] = { 431, 1285, 1, -60, critChance = 5, levelRequirement = 69, manaCost = 4, statInterpolation = { }, },
[30] = { 454, 1353, 1, -60, critChance = 5, levelRequirement = 70, manaCost = 4, statInterpolation = { }, },
[31] = { 477, 1424, 1, -60, critChance = 5, levelRequirement = 71, manaCost = 4, statInterpolation = { }, },
[32] = { 502, 1498, 1, -60, critChance = 5, levelRequirement = 72, manaCost = 4, statInterpolation = { }, },
[33] = { 529, 1577, 1, -60, critChance = 5, levelRequirement = 73, manaCost = 4, statInterpolation = { }, },
[34] = { 556, 1658, 1, -60, critChance = 5, levelRequirement = 74, manaCost = 4, statInterpolation = { }, },
[35] = { 585, 1744, 1, -60, critChance = 5, levelRequirement = 75, manaCost = 4, statInterpolation = { }, },
[36] = { 615, 1834, 1, -60, critChance = 5, levelRequirement = 76, manaCost = 4, statInterpolation = { }, },
[37] = { 647, 1929, 1, -60, critChance = 5, levelRequirement = 77, manaCost = 4, statInterpolation = { }, },
[38] = { 680, 2028, 1, -60, critChance = 5, levelRequirement = 78, manaCost = 4, statInterpolation = { }, },
[39] = { 715, 2132, 1, -60, critChance = 5, levelRequirement = 79, manaCost = 4, statInterpolation = { }, },
[40] = { 751, 2241, 1, -60, critChance = 5, levelRequirement = 80, manaCost = 4, statInterpolation = { }, },
[41] = { 790, 2355, 1, -60, critChance = 5, levelRequirement = 81, manaCost = 4, statInterpolation = { }, },
[42] = { 830, 2475, 1, -60, critChance = 5, levelRequirement = 82, manaCost = 4, statInterpolation = { }, },
},
}
skills["RockGolemSlam"] = {
name = "Slam",
hidden = true,
color = 1,
skillTypes = { [1] = true, [11] = true, },
castTime = 1,
baseFlags = {
attack = true,
melee = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"active_skill_attack_speed_+%_final",
"chance_to_taunt_on_hit_%",
"skill_art_variation",
"active_skill_area_of_effect_radius_+%_final",
"is_area_damage",
},
levels = {
[1] = { -20, 33, 1, 0, damageMultiplier = 75, cooldown = 6, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["RockGolemWhirlingBlades"] = {
name = "Roll",
hidden = true,
color = 4,
description = "Dive through enemies, dealing weapon damage. Only works with daggers, claws and one handed swords.",
skillTypes = { [1] = true, [6] = true, [24] = true, [38] = true, },
weaponTypes = {
["Thrusting One Handed Sword"] = true,
["Claw"] = true,
["Dagger"] = true,
["One Handed Sword"] = true,
},
castTime = 2.6,
baseFlags = {
attack = true,
melee = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"skill_sound_variation",
"active_skill_attack_speed_+%_final",
"monster_flurry",
"cast_time_overrides_attack_duration",
"ignores_proximity_shield",
},
levels = {
[1] = { 1, -50, 1, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["ZombieSlam"] = {
name = "Slam",
hidden = true,
color = 4,
skillTypes = { [1] = true, [11] = true, },
castTime = 1,
baseFlags = {
attack = true,
melee = true,
area = true,
},
baseMods = {
skill("radius", 18),
},
qualityStats = {
},
stats = {
"active_skill_attack_speed_+%_final",
"active_skill_damage_+%_final",
"base_skill_effect_duration",
"is_area_damage",
},
levels = {
[1] = { -22, 45, 280, cooldown = 5, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["SpiderMinionLeapSlam"] = {
name = "Leap Slam",
hidden = true,
color = 4,
description = "Jump into the air, damaging enemies (and knocking back some) with your main hand where you land. Enemies you would land on are pushed out of the way. Requires an axe, mace, sword or staff.",
skillTypes = { [1] = true, [6] = true, [7] = true, [11] = true, [24] = true, [38] = true, },
weaponTypes = {
["One Handed Mace"] = true,
["Sceptre"] = true,
["Thrusting One Handed Sword"] = true,
["Two Handed Sword"] = true,
["Staff"] = true,
["Two Handed Axe"] = true,
["Two Handed Mace"] = true,
["One Handed Axe"] = true,
["One Handed Sword"] = true,
},
castTime = 1.4,
baseFlags = {
attack = true,
melee = true,
area = true,
},
baseMods = {
},
qualityStats = {
},
stats = {
"skill_art_variation",
"active_skill_area_of_effect_radius_+%_final",
"is_area_damage",
"cast_time_overrides_attack_duration",
},
levels = {
[1] = { 3, 0, damageMultiplier = 50, cooldown = 2, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["DancingDervishCyclone"] = {
name = "Cyclone",
hidden = true,
color = 2,
description = "Damage enemies around you, then perform a spinning series of attacks as you travel to a target location.",
skillTypes = { [1] = true, [6] = true, [11] = true, [24] = true, [38] = true, },
weaponTypes = {
["None"] = true,
["One Handed Mace"] = true,
["Sceptre"] = true,
["Thrusting One Handed Sword"] = true,
["Two Handed Sword"] = true,
["Dagger"] = true,
["Staff"] = true,
["Two Handed Axe"] = true,
["Two Handed Mace"] = true,
["One Handed Axe"] = true,
["Claw"] = true,
["One Handed Sword"] = true,
},
castTime = 1,
baseFlags = {
attack = true,
area = true,
melee = true,
},
baseMods = {
skill("dpsMultiplier", 2),
skill("radiusIsWeaponRange", true),
},
qualityStats = {
},
stats = {
"physical_damage_+%",
"attack_speed_+%",
"skill_art_variation",
"cyclone_movement_speed_+%_final",
"cyclone_extra_distance",
"active_skill_damage_+%_final",
"is_area_damage",
},
levels = {
[1] = { 0, 20, 0, 0, 25, 0, levelRequirement = 1, statInterpolation = { }, },
},
}
skills["MinionInstability"] = {
name = "Minion Instability",
hidden = true,
color = 4,
baseFlags = {
cast = true,
area = true,
fire = true,
},
skillTypes = { [10] = true, },
baseMods = {
skill("FireMin", 1, { type = "PerStat", stat = "Life", div = 1/.33 }),
skill("FireMax", 1, { type = "PerStat", stat = "Life", div = 1/.33 }),
skill("showAverage", true),
skill("radius", 22),
},
qualityStats = {
},
levelMods = {
},
levels = {
[1] = { },
},
stats = {
},
statLevels = {
},
}
skills["BeaconCausticCloud"] = {
name = "Caustic Cloud",
hidden = true,
color = 4,
baseFlags = {
cast = true,
area = true,
chaos = true,
},
skillTypes = { },
baseMods = {
skill("ChaosDot", 1, { type = "PerStat", stat = "Life", div = 10 }),
skill("dotIsArea", true),
},
qualityStats = {
},
levelMods = {
},
levels = {
[1] = { },
},
stats = {
},
statLevels = {
},
}
skills["BeaconZombieCausticCloud"] = {
name = "Caustic Cloud",
hidden = true,
color = 4,
baseFlags = {
cast = true,
area = true,
chaos = true,
},
skillTypes = { },
baseMods = {
skill("ChaosDot", 1, { type = "PerStat", stat = "Life", div = 2 }),
skill("dotIsArea", true),
},
qualityStats = {
},
levelMods = {
},
levels = {
[1] = { },
},
stats = {
},
statLevels = {
},
}
|
local Helpers = {}
function Helpers.p(...)
print(vim.inspect(...))
end
function Helpers.pr(str)
local s = ""
if type(str) == "string" then
s = str
else
s = vim.inspect(str)
end
s = vim.split(s, "\n")
local buffer = repl:buffer()
local n = vim.api.nvim_buf_line_count(buffer)
vim.api.nvim_buf_set_lines(buffer, n, -1, false, s)
end
function Helpers.unescape(str)
-- anytype => vim.inspect(anytype)
-- "string" => "string" // unchanged
-- "\"string\"" => "string" // unescaped
if not (type(str) == "string") then
return vim.inspect(str)
end
local unescaped = loadstring("return "..str)()
if type(unescaped) == "string" then
return unescaped
else
return tostring(unescaped)
end
end
function Helpers.every(fn, coll)
if #coll == 0 then return true end
local res = true
for k,v in pairs(coll) do
res = res and fn(v)
end
return res
end
function Helpers.isemptystr(str)
return string.gsub(str, "^%s+$", "") == ""
end
function Helpers.isempty(elem, depth)
if type(elem) == "string" then
return Helpers.isemptystr(elem)
end
if type(depth) == "number" then depth = depth - 1 end
if type(elem) == "table" then
if (type(depth) == "number") and depth < 0 then
return false
else
return Helpers.every(function(element)
return Helpers.isempty(element, depth)
end, elem)
end
else
return Helpers.isemptystr(elem)
end
end
function Helpers.run_in_buffer(fn, target_buf)
local target_win = Helpers.filter(function(win)
return target_buf == vim.api.nvim_win_get_buf(win)
end, vim.api.nvim_list_wins())[1]
local current_win = vim.api.nvim_get_current_win()
local cursor_pos = vim.api.nvim_win_get_cursor(current_win)
local current_buf = vim.api.nvim_get_current_buf()
vim.api.nvim_set_current_win(target_win)
-- vim.api.nvim_set_current_buf(target_buf)
local ret = vim.schedule_wrap(function(tb)
fn(tb)
end)(target_buf)
vim.api.nvim_set_current_win(current_win)
-- vim.api.nvim_set_current_buf(current_buf)
vim.api.nvim_win_set_cursor(current_win, cursor_pos)
return ret
end
function Helpers.occur(str, tag)
local t = {}
local i = 0
while true do
i = string.find(str, tag, i+1)
if not i then break end
table.insert(t, i)
end
return #t > 0 and t
end
function Helpers.log(arg)
local str = string.gsub(tostring(arg), "\n", "")
vim.api.nvim_command("call input(\""..str.."\")")
end
function Helpers.identity(arg)
return arg
end
function Helpers.getvar(name, default)
if pcall(function () vim.api.nvim_get_var(name) end) then
return vim.api.nvim_get_var(name)
else
return default
end
end
function Helpers.last(t)
if not type(t) == "table" then return nil end
return t[table.maxn(t)]
end
function Helpers.butlast(t)
local copy = vim.deepcopy(t)
table.remove(copy,table.maxn(t))
return copy
end
function Helpers.first(t)
if not type(t) == "table" then return nil end
return t[1]
end
function Helpers.rest(t)
local copy = vim.deepcopy(t)
table.remove(copy,1)
return copy
end
function Helpers.contains(list, x)
if not list then return false end
for _, v in pairs(vim.tbl_flatten(list)) do
if v == x then return true end
end
return false
end
function Helpers.keys(t)
local keys = {}
for k,v in pairs(t) do
table.insert(keys,k)
end
return keys
end
function Helpers.filter(fn, t)
local filtered = {}
for k,v in pairs(t) do
if fn(v,k) then
table.insert(filtered,v)
end
end
return filtered
end
function Helpers.remove(fn, t)
local filtered = {}
for k,v in pairs(t) do
if not fn(v,k) then
table.insert(filtered,v)
end
end
return filtered
end
function Helpers.map(f, t)
local new_t = {}
for i,v in ipairs(vim.tbl_flatten(t)) do
table.insert(new_t, f(v))
end
return new_t
end
return Helpers
|
--====================================================================--
-- lua_states.lua
--
-- Documentation: http://docs.davidmccuskey.com/display/docs/lua_states.lua
--====================================================================--
--[[
The MIT License (MIT)
Copyright (C) 2013-2014 David McCuskey. All Rights Reserved.
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.
--]]
--====================================================================--
-- DMC Lua Library : Lua States
--====================================================================--
-- Semantic Versioning Specification: http://semver.org/
local VERSION = "1.1.0"
--====================================================================--
-- Support Functions
function outStr( msg )
return "Lua States (debug) :: " .. tostring( msg )
end
function errStr( msg )
return "\n\nERROR: Lua States :: " .. tostring( msg ) .. "\n\n"
end
--====================================================================--
-- States Container
--====================================================================--
local States = {}
--== State API Methods ==--
function States._getState( self )
return self.__curr_state_name
end
function States._setState( self, state_name )
assert( state_name, errStr("missing state name") )
assert( type(state_name)=='string', errStr("state name must be string'" .. tostring( state_name ) ) )
if self.__debug_on then
print( outStr("setState: is now '" .. tostring( state_name ) .. "'" ) )
end
local f = self[ state_name ]
assert( type(f)=='function', errStr("missing method for state name: '" .. tostring( state_name ) ) )
self.__curr_state_func = f
self.__curr_state_name = state_name
end
function States._gotoState( self, state_name, ... )
assert( state_name, errStr("no state name given") )
assert( self.__curr_state_func, errStr("no initial state method") )
if self.__debug_on then
print( outStr( "gotoState: '" .. self.__curr_state_name .. "' >> '".. tostring( state_name ) .. "'" ) )
end
self:pushStateStack( self.__curr_state_name )
self.__curr_state_func( self, state_name, ... )
end
function States._getPreviousState( self )
assert( #self.__state_stack > 0, errStr("state stack is empty") )
return self.__state_stack[1]
end
function States._gotoPreviousState( self, ... )
local state_name = self:popStateStack()
assert( state_name, errStr("no state name given") )
assert( self.__curr_state_func, errStr("no initial state method") )
if self.__debug_on then
print( outStr( "gotoPreviousState: going to >> " .. tostring( state_name ) ) )
end
self.__curr_state_func( self, state_name, ... )
end
function States._pushStateStack( self, state_name )
assert( state_name, errStr("no state name given") )
table.insert( self.__state_stack, 1, state_name )
end
function States._popStateStack( self )
assert( #self.__state_stack > 0, errStr("state stack is empty") )
return table.remove( self.__state_stack, 1 )
end
function States._resetStates( self )
if self.__debug_on then
print( outStr("resetStates: resetting object states") )
end
self.__state_stack = {}
self.__curr_state_func = nil
self.__curr_state_name = ""
self.__debug_on = false
end
function States._setDebug( self, value )
self.__debug_on = value
end
-- private method, for testing
function States._stateStackSize( self )
return #self.__state_stack
end
--== Facade API Methods ==--
function States._mixin( obj )
obj = obj or {}
-- add variables
States._resetStates( obj )
-- add methods
obj.getState = States._getState
obj.setState = States._setState
obj.gotoState = States._gotoState
obj.getPreviousState = States._getPreviousState
obj.gotoPreviousState = States._gotoPreviousState
obj.pushStateStack = States._pushStateStack
obj.popStateStack = States._popStateStack
obj.resetStates = States._resetStates
obj.setDebug = States._setDebug
-- private method, for testing
obj._stateStackSize = States._stateStackSize
return obj
end
--====================================================================--
-- States Facade
--====================================================================--
return {
setDebug = States._setDebug,
mixin = States._mixin
}
|
local _, addon = ...
local AdiBags = LibStub("AceAddon-3.0"):GetAddon("AdiBags")
local FilterName = 'MagiDetailedFilters'
local MatchIDs
local Tooltip
local Result = {}
local CategoryStorage = {}
local function FormatListForAdiBags(List)
Set = {}
for _, v in ipairs(List) do
Set[v] = true
end
return Set
end
local function FormatIds()
wipe(Result)
for _StoreName, Store in pairs(addon.magi.Store) do
for _CategoryName, Category in pairs(Store) do
for SectionName, Section in pairs(Category) do
local name = addon.magi.SetLabel(Section.Color, SectionName, _StoreName)
Result[name] = FormatListForAdiBags(Section.Ids)
if not CategoryStorage[name] then CategoryStorage[name] = Section.CategoryType end
end
end
end
return Result
end
local function Tooltip_Init()
local tip, leftside = CreateFrame("GameTooltip"), {}
for i = 1, 6 do
local Left, Right = tip:CreateFontString(), tip:CreateFontString()
Left:SetFontObject(GameFontNormal)
Right:SetFontObject(GameFontNormal)
tip:AddFontStrings(Left, Right)
leftside[i] = Left
end
tip.leftside = leftside
return tip
end
local setFilter = AdiBags:RegisterFilter(FilterName, 99, "ABEvent-1.0")
setFilter.uiName = FilterName
setFilter.uiDesc = "Magi's Detailed Filters"
function setFilter:OnInitialize()
self.db = AdiBags.db:RegisterNamespace(FilterName, {
profile = {}
})
AdiBags:Print("Adibags - Magi's Detailed Filters loaded")
end
function setFilter:Update()
MatchIDs = nil
self:SendMessage("AdiBags_FiltersChanged")
end
function setFilter:OnEnable()
AdiBags:UpdateFilters()
end
function setFilter:OnDisable()
AdiBags:UpdateFilters()
end
function setFilter:Filter(slotData)
MatchIDs = MatchIDs or FormatIds(self)
for i, name in pairs(MatchIDs) do
if name[slotData.itemId] then
return i, CategoryStorage[i]
end
end
Tooltip = Tooltip or Tooltip_Init()
Tooltip:SetOwner(UIParent,"ANCHOR_NONE")
Tooltip:ClearLines()
if slotData.bag == BANK_CONTAINER then
Tooltip:SetInventoryItem("player", BankButtonIDToInvSlotID(slotData.slot, nil))
else
Tooltip:SetBagItem(slotData.bag, slotData.slot)
end
Tooltip:Hide()
end
function setFilter:GetOptions()
return {},
AdiBags:GetOptionHandler(self, false, function ()
return self:Update()
end)
end
|
--[[--------------------------------------------------------
-- Database - A Database Asbraction Layer for Lua --
-- Copyright (c) 2014-2015 TsT worldmaster.fr --
--]]--------------------------------------------------------
-- a voir :
-- https://github.com/FPtje/MySQLite/blob/master/mysqlite.lua
-- https://github.com/esmil/lem-sqlite3/blob/master/lem/sqlite3/queued.lua
-- https://github.com/moteus/lua-sqlite3/blob/master/sqlite3.lua
local sqlite3 = require "luasql.sqlite3"
if type(sqlite3) == "table" and type(sqlite3.sqlite3) == "function" then -- I dunno why the sqlite3 module is inside the "luasql.sqlite3" module
sqlite3 = sqlite3.sqlite3
end
local databaseschema = require("databaseschema")
local schemaToSql = assert(databaseschema.schemaToSql)
local schemaIsValid = assert(databaseschema.schemaIsValid)
local schemaTables = assert(databaseschema.schemaTables)
local cc2 = require("classcommons2")
local class, instance = assert(cc2.class), assert(cc2.instance)
local _M = {}
_M.printdebug = function() end
local function _init(self)
self.printdebug = _M.printdebug
-- self:printdebug("dbClass init()")
-- self:newenv()
end
local mtClass = {}
mtClass.init = assert(_init)
local dbClass = class("dbClass", assert(mtClass) )
-- 30log specific printing feature (see: https://github.com/Yonaba/30log/#printing-classes-and-objects )
local function new()
return instance(dbClass)
end
function dbClass:newenv()
-- self:printdebug("dbClass env new()")
local env = assert(sqlite3())
self.env = env
return
end
function dbClass:setSchema(schema)
local valid, reason = schemaIsValid(schema)
if not valid then
error(reason, 2)
end
local schemas = self.schema or {}
for k,v in pairs(schema) do
schemas[k] = v
end
self.schema = schemas
return
end
-- db:unsetSchema(schema)
-- schema: can be key-table or itable
-- schema {['t1']=true, 't2'} forgot tables t1 and t2
function dbClass:unsetSchema(schema)
local schemas = self.schema or {}
for k,v in pairs(schema) do
if type(k) == "number" then
if schemas[v] then
schemas[v] = nil
end
elseif schemas[k] then
schemas[k] = nil
end
end
self.schema = schemas
return
end
-- expose the schema
function dbClass:getSchema()
return self.schema
end
function dbClass:schemaTables()
return schemaTables(self.schema)
end
-- setBackend <dbtype>
-- valid dbtypes : 'mysql'|'sqlite'
function dbClass:setBackend(dbtype)
self.dbtype = dbtype
return self
end
--dbfile = "/tmp/luasql-test"
--dbfile = "" -- temporary (no file created)
--dbfile = ":memory:" -- in memory (no file created)
function dbClass:open(dbfile)
local dbfile = dbfile or ""
if not self.env then self:newenv() end
local env = assert(self.env)
assert(self.con == nil, "DB seems already opened")
local con
local ok, err = pcall( function() con = assert(env:connect(dbfile)) end )
if not ok then
error("Fail to open database "..tostring(dbfile).."\nenv:connect() error message: "..err, 2)
end
self.con = con
self:printdebug("dbClass con new()")
self.dbfile = dbfile
con:setautocommit(true)
return self
end
function dbClass:close()
self:printdebug("db:close()")
if self.curs then
for cur in pairs(self.curs) do
--self:printdebug("dbClass curs close():"..tostring(cur))
if cur ~= "n" then
cur:close()
self.curs[cur] = nil
self.curs.n = self.curs.n -1
end
end
end
if self.con then
self.con:close()
self.con = nil
--self:printdebug("dbClass con close()")
end
if self.env then
self.env:close()
self.env = nil
--self:printdebug("dbClass env close()")
end
end
local function assertcon(con, msg)
if con == nil then
error(msg or "DB is not open. Use db:open() first.", 3)
end
return con
end
local function handleforvalue(value)
local fetch = function() return 1, value end
return setmetatable({
fetch = fetch,
fetchall = function() return {value} end,
close = function() end,
}, { __call = fetch, }) --TODO: __tostring
end
local function execute(self, sql_statement)
local conn = assertcon(self.con)
-- retrieve a cursor
local cursor = conn:execute(sql_statement)
if type(cursor) == "number" or type(cursor) == "string" or type(cursor) == "nil" then
return handleforvalue(cursor)
end
local cursors = self.curs or {}
self.curs = cursors
cursors[cursor] = true
cursors.n = (cursors.n or 0) +1
local close = function()
if cursors[cursor] then
self:printdebug("cursor:close()")
cursor:close()
cursors[cursor] = nil
cursors.n = cursors.n -1
end
end
local function closeifnotresult(...)
if #{...} == 0 then
close()
end
return ...
end
local fetch = function(_self_, tab, mode)
--local tab = tab == nil and {} or tab -- default with tab
--local mode = mode == nil and "a" or mode -- default key index
return closeifnotresult(cursor:fetch(tab, mode)) -- cur:fetch({}, "a")
end
local fetchall = function(_self_, tab, mode)
local mode = mode == nil and "a" or mode -- default key index
local tab = tab or {}
while true do
--local ok, row = pcall(cursor.fetch, cursor, {}, mode)
--if not ok then
-- close()
-- self:printdebug("break coz error:", row)
-- break
--end
local row = closeifnotresult(cursor:fetch({}, mode))
if not row then break end
tab[#tab+1] = row
end
close()
return tab, mode
end
local fetchvalues = function(_self_, tab, mode)
--local mode = mode == nil and "a" or mode -- default key index
local tab = tab or {}
local tab = { closeifnotresult(cursor:fetch()) }
close()
return tab
end
return setmetatable({
fetch = fetch,
fetchall = fetchall,
fetchvalues = fetchvalues,
close = close,
}, { __call = fetch, }) --TODO: __tostring
end
function dbClass:cursors()
return self.curs and self.curs.n or 0
end
function dbClass:pragmaQuery(sqlpart)
assertcon(self.con)
local sql = ("PRAGMA %s;"):format(sqlpart)
local hand = execute(self, sql)
--print("dbClass:pragmaQuery(sqlpart)="..sqlpart)
local res = hand:fetchall()
--print("res=",res, "#res=", #res)
for k, v in pairs(res) do
if type(v) == "table" then
for k2,v2 in pairs(v) do
print(k, k2, v2)
end
else
print(k, tostring(v))
end
end
local cur = nil
--[[ if type(cur) == "number" or type(cur) == "string" or cur == nil then
print("cur=", cur)
return true, nil, nil
end
local res
if cur and cur.fetch then
ret = cur:fetch({}, "a")
if res ~= "ok" then
return false, res, cur
end
end
]]--
return true, res, cur
end
-- https://www.sqlite.org/pragma.html#pragma_query_only
-- PRAGMA query_only;
-- PRAGMA query_only = boolean;
-- WARNING: sqlite3 seems buggy, the query_only seems not available at all!
-- WORKAROUND: we should emul it softly ?
function dbClass:readonly(ro)
if ro == nil then
-- ask the DB ? PRAGMA query_only; ?
return self.readonly -- return the current state
end
if type(ro)~="boolean" then
error("bad argument #1 to 'readonly' (boolean expected, got "..type(ro)..")", 2)
end
local ok, err, cur = self:pragmaQuery("query_only = "..tostring(ro))
if ok then
self.readonly = ro
end
if cur then cur:close() end
return ok, err
end
-- https://www.sqlite.org/pragma.html#pragma_quick_check
-- PRAGMA quick_check;
-- PRAGMA quick_check(N)
-- https://www.sqlite.org/pragma.html#pragma_integrity_check
-- PRAGMA integrity_check; (default N=100)
-- PRAGMA integrity_check(N) (if error, N first error returns else return string'ok')
function dbClass:dbcheck(fast, N)
if fast == nil then fast = false end
if type(fast) ~= "boolean" then
error("bad argument #1 to 'dbcheck' (boolean or nil expected, got "..type(fast)..")", 2)
end
local sqlpart =
(fast and "quick_check" or "integrity_check")..
(N and "("..N..")" or '')
local ok, res, cur = self:pragmaQuery(sqlpart)
if not ok then
print("DB[sqlite] dbcheck got errors:")
if type(res) == "table" then
for k,e in pairs(res) do
print(k, e) -- print errors
end
else
print(tostring(res))
end
print("DB[sqlite] end of dbcheck")
end
if cur then cur:close() end
return ok
end
function dbClass:reset()
local dbtype, schema = self.dbtype, self.schema
assert(dbtype, "'dbtype' is not set. Use db:setBackend() first.")
assert(schema, "schema is not set. Use db:setSchema() first.")
assertcon(self.con)
for tablename in pairs(schema) do
self:drop(tablename)
end
for tablename in pairs(schema) do
self:schemaCreate(tablename)
end
return
end
function dbClass:schemaCreate()
local dbtype, schema = self.dbtype, self.schema
assert(dbtype, "'dbtype' is not set. Use db:setBackend() first.")
assert(schema, "schema is not set. Use db:setSchema() first.")
assertcon(self.con)
local initSql = schemaToSql(schema, dbtype)
for i,sql in ipairs(initSql) do
-- self:printdebug("---------------------------------")
self:printdebug(sql)
local hand = execute(self, sql)
hand:close()
-- self:printdebug("initSql done, returns "..tostring(res))
end
-- self:printdebug("---------------------------------")
end
function dbClass:escape(data)
-- data:gsub("'", "''") ?
local con = assertcon(self.con)
return con:escape(data)
end
function dbClass:setautocommit(value)
assert(type(value) == "boolean", "bad argument #2 to 'install' (table expected, got "..type(value)..")")
local con = assertcon(self.con)
con:setautocommit(not not value)
return
end
function dbClass:begin()
local con = assertcon(self.con)
local hand = execute(self, "BEGIN TRANSACTION;")
hand:close()
end
function dbClass:commit()
local con = assertcon(self.con)
local hand = execute(self, "COMMIT TRANSACTION;")
hand:close()
end
function dbClass:transation(func, ...)
local commitreturn = function(...)
self:commit()
return ...
end
self:begin()
return commitreturn(func(...))
end
function dbClass:create(name, columns)
end
function dbClass:drop(name)
local dbtype, schema, con = self.dbtype, self.schema, assertcon(self.con)
assert(dbtype, "'dbtype' is not set. Use db:setBackend() first.")
assert(schema, "schema is not set. Use db:setSchema() first.")
local dropsql = ("DROP TABLE IF EXISTS %s;"):format(name) -- should be generated from shema layer (with dbtype)?
self:printdebug(dropsql)
local hand = execute(self, dropsql)
return hand:fetchall()
end
function dbClass:inserts(name, t_rows)
for i,row in ipairs(t_rows) do
local res = self:insert(name, row)
assert(res == nil or res == 0)
end
end
-- :insert <(string)SQL statement> raw sql insert
-- :insert <key-value table> insert value by column+value way
-- :insert <value table> insert values in order
--
function dbClass:insert(name, row)
assert(type(row) == "table")
local con = assertcon(self.con)
local sql
if type(row) == "table" then
local protect = function(fieldvalue)
if type(fieldvalue) == "table" and type(fieldvalue.raw) == "string" then -- the way to use an unquoted string
-- fieldvalue={raw="SQL STUFF"}
return fieldvalue.raw
elseif type(fieldvalue) == "string" then
return "'"..con:escape(fieldvalue).."'" -- lua string, auto-quoted
elseif type(fieldvalue) == "number" then
return tostring(fieldvalue) -- lua number
end
error("WARNING: field "..fieldname.." have invalid data type ("..type(fieldvalue).."). Allowed type are string/number/table with 'raw' key.")
return tostring(fieldvalue) -- not a string, not a number, !?!
end
if #row == 0 then -- key/value
local fieldnames = {}
local fieldvalues = {}
for fieldname, fieldvalue in pairs(row) do
fieldnames[#fieldnames+1] = con:escape(fieldname)
fieldvalues[#fieldvalues+1] = protect(fieldvalue)
end
sql = ("INSERT INTO %s(%s) VALUES(%s);"):format(name, table.concat(fieldnames, ", "), table.concat(fieldvalues, ", "))
else
local fieldvalues = {}
for i,fieldvalue in ipairs(row) do
fieldvalues[#fieldvalues+1] = protect(fieldvalue)
end
sql = ("INSERT INTO %s VALUES(%s);"):format(name, table.concat(fieldvalues, ", "))
end
elseif type(row) == "string" then
sql = row
else
error("dbClass:insert(): invalid format for row: "..type(row))
end
-- self:printdebug(sql)
local hand = execute(self, sql)
local ret = table.concat(hand:fetchall(nil, "n"), ";")
-- self:printdebug("returns "..tostring(ret))
return ret
end
-- Challenge: be able to cur:close() at the end of data (and how to close before the end of data when the application quit)
-- 1) luasql for sqlite does not support cursor.numrows()
-- if cursor.numrows then
-- local n = cursor:numrows()
-- -- check if cursor still have data, if not, con:close()
-- if n == 0 then
-- print("cursor (closed?)", n)
-- else
-- print("cursor", n)
-- end
-- end
-- 2) close the cursor at runtime when no more data is got (when the result is empty, no argument at all)
-- Problem: if the result is only 1 value, the coder will usually forgot to close the handler...
-- 3) solution: index all cursors, and auto close when no more result, force close with result:close() or close all cursors on db:close()
-- result(...)
-- result:fetch(...)
-- result:fetchall()
-- result:close()
-- db:select <name>, <w>, [<action>]
-- <name> : the table name
-- <w> : a table containing :
-- - columns = "field1,field2,..."|"*"
-- - where = "sql-where-close"
-- - limit = "sql-limit-close"
-- - orderby = "sql-orderby-close"
-- <action>: not-used-yet
-- db:select("t1", {columns="x,y,z", where="x == 'titi'", limit="1", orderby="x ASC",}, nil)
function dbClass:select(name, w, action)
local dbtype, schema, con = self.dbtype, self.schema, assertcon(self.con)
assert(dbtype, "'dbtype' is not set. Use db:setBackend() first.")
assert(schema, "schema is not set. Use db:setSchema() first.")
local columns, where, limit, orderby
if type(w) == "string" then
columns = w
elseif type(w) == "table" then
columns = w.columns
columns = (type(columns) == "table" and table.concat(columns, ", ")) or columns
assert(columns, "bad argument #2 to 'select' (missing mandatory 'columns' field in table)")
where = w.where
where = where and ' WHERE '..where
limit = w.limit
limit = limit and ' LIMIT '..limit
orderby = w.orderby
orderby = orderby and ' ORDER BY '..orderby
else
error("bad argument #2 to 'select' (string or table expected, got "..type(w)..")", 2)
end
local sql = ("SELECT %s FROM %s%s%s%s;"):format(columns or '*', name, where or '', orderby or '', limit or '')
self:printdebug(sql)
return execute(self, sql)
end
-- :query() -- table/value result ?
-- :queryvalue() -- 1 value
-- :haveoneresult() -- error if more than one result ?
-- :lasterror ? --
-- :queryraw(...) --
-- SQLStr -- alias for escape
-- TableExists -- alias for exists
-- compat with https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index27a7.html
function dbClass:update(name, set, action)
end
function dbClass:delete(name, action)
end
-- FIXME: not working correctly
--[=[
function dbClass:getColumns(table_name)
local con = assertcon(self.con)
local cur = con:execute( ("SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = 'table'"):format( con:escape(table_name) ) )
print(cur)
-- local cur = con:execute( ("PRAGMA table_info(%s);"):format( con:escape(table_name) ) )
-- local row = cur:fetch({}, "a")
-- while row do
-- print(string.format("Name: %s, E-mail: %s", row.name, row.email))
-- -- reusing the table of results
-- row = cur:fetch (row, "a")
-- end
--local row = cur:fetch({}, "a")
for k,v in pairs( cur:getcolnames() ) do
print(k,v)
end
-- while row do
-- for k,v in pairs(row) do
-- print(k,v)
-- end
-- row = cur:fetch(row, "a")
-- end
cur:close()
return
end
]=]--
function dbClass:getRows(name)
--return #self.data[name][1]
end
function dbClass:exists(name) -- table exists ? column exists ? entry exists ?
--return self.data[name] ~= nil
end
function dbClass:query(query)
end
_M.new = new
return _M
|
--[[---------------------------------------------------------------------------
gName-Changer | LANGUAGE FILE
This addon has been created & released for free
by Gaby
Steam : https://steamcommunity.com/id/EpicGaby
-----------------------------------------------------------------------------]]
-- Russian translation by : https://gmod.facepunch.com/u/usfs/qFamouse/
gNameChanger.Language = {
--[[-------------------------------------------------------------------------
SERVER SIDE TRANSLATIONS
---------------------------------------------------------------------------]]
needWait = "Вы должны подождать {{delay}} секунд между каждой смены имени.",
needMoney = "Извините! У вас недостаточно денег, чтобы изменить свое имя!",
needRight = "Извините! У вас нет разрешения на смену имени.",
noEnts = "Нет энтити для защиты.",
entsSaved = "Все NPC были сохранены в {{path}}",
configSaved = "The configuration has been saved.",
nameBlacklist = "The name you entered is blacklisted."
--[[-------------------------------------------------------------------------
CLIENT SIDE TRANSLATIONS
---------------------------------------------------------------------------]]
entHint = "Нажмите {{key_use}} Для смены рп ника (за деньги)",
changeName = "СМЕНА ИМЕНИ",
name = "Имя :",
lastName = "Фамилия :",
changeBut = "Готово! Меняем! ( {{device}}{{price}} )",
welcome = "Здравствуйте {{plyname}}. Чем я могу вам помочь?",
sorry = "У меня нет денег, простите...",
secretary = "СЕКРЕТАРЬ",
wantChange = "Я хочу изменить свою фамилию и имя!",
wrongChoose = "Ой простите, Я ошибся. До свидания!",
administration = "ADMINISTRATION",
saveConfig = "Save this configuration",
blacklist = "Blacklisted words",
activeList = "Active blacklist"
} |
fx_version "cerulean"
games { "gta5" }
ui_page "html/ui.html"
files {
"html/ui.html",
"html/js/*.js",
"html/css/*.css",
"html/webfonts/*.eot",
"html/webfonts/*.svg",
"html/webfonts/*.ttf",
"html/webfonts/*.woff",
"html/webfonts/*.woff2",
}
shared_scripts {
"@caue-lib/shared/sh_models.lua",
"@caue-lib/shared/sh_util.lua",
"shared/*",
}
server_scripts {
"server/*",
}
client_scripts {
"@caue-lib/client/cl_state.lua",
"client/*",
"client/entries/*",
} |
local ABILITY = script:GetCustomProperty("Ability"):WaitForObject()
local PARENT = script:GetCustomProperty("Parent"):WaitForObject()
local TAG = script:GetCustomProperty("Tag")
local effects = {}
for _, obj in ipairs(PARENT:FindDescendantsByType("Vfx")) do
if obj:GetCustomProperty("Tag") == TAG then
table.insert(effects, obj)
end
end
for _, obj in ipairs(PARENT:FindDescendantsByType("Audio")) do
if obj:GetCustomProperty("Tag") == TAG then
table.insert(effects, obj)
end
end
function PlayEffects()
for _, value in ipairs(effects) do
value:Play()
end
end
ABILITY.executeEvent:Connect(PlayEffects) |
object_tangible_food_generic_dish_synthsteak = object_tangible_food_generic_shared_dish_synthsteak:new {
}
ObjectTemplates:addTemplate(object_tangible_food_generic_dish_synthsteak, "object/tangible/food/generic/dish_synthsteak.iff")
|
pfDB["quests-itemreq"]["data-turtle"] = {
[51425] = {
[51301] = 0,
},
[60329] = {
[1547] = 0,
},
[60330] = {
[1553] = 0,
},
[60331] = {
[80466] = 0,
},
}
|
local include = require 'include'
local ffi = require 'ffi'
local serialization = require('serialization');
local util = require 'util'
local Serial = require('Serial');
local kBPacket = require('kBPacket');
ffi.cdef[[
typedef long int __time_t;
typedef long int __suseconds_t;
typedef struct timeval {
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]
function utime()
local t = ffi.new('struct timeval')
ffi.C.gettimeofday(t, nil)
return t.tv_sec + 1e-6 * t.tv_usec
end
function usleep(s)
ffi.C.poll(nil, 0, s * 1000)
end
baud = 230400;
dev = '/dev/ttyUSB0';
s1 = Serial.connect(dev, baud);
packetID = -1;
function ReceivePacket()
if packetID < 0 then
packetID = kBPacket.create();
end
buf, buftype, bufsize = Serial.read(1000, 20000);
-- return buf, bufsize
packet, packetType, packetSize, buf2, buf2type, buf2Size = kBPacket.processBuffer(packetID, buf, bufsize);
return packet, packetSize;
end
function cdata2gpsstring(cdata, len)
str = '';
for i = 5, len - 1 - 8 do
str = str..string.format('%c', cdata[i])
end
return str
end
function cdata2string(cdata, len)
str = '';
for i = 0, len - 1 do
str = str..string.format('%c', cdata[i])
end
return str
end
function extractImu(imustr, len)
local imu = {}
imu.type = 'imu'
-- imustr = ffi.new("uint8_t[?]", #imustrs, imustrs)
imu.tuc = tonumber(ffi.new("uint32_t", bit.bor(bit.lshift(imustr[8], 24),
bit.lshift(imustr[7], 16), bit.lshift(imustr[6], 8), imustr[5])))
imu.id = tonumber(ffi.new("double", imustr[9]))
imu.cntr = tonumber(ffi.new("double", imustr[10]))
rpyGain = 5000
imu.r = tonumber(ffi.new('int16_t', bit.bor(bit.lshift(imustr[12], 8), imustr[11]))) / rpyGain
imu.p = tonumber(ffi.new('int16_t', bit.bor(bit.lshift(imustr[14], 8), imustr[13]))) / rpyGain
imu.y = tonumber(ffi.new('int16_t', bit.bor(bit.lshift(imustr[16], 8), imustr[15]))) / rpyGain
wrpyGain = 500
imu.wr = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[18], 8), imustr[17]))) / wrpyGain
imu.wp = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[20], 8), imustr[19]))) / wrpyGain
imu.wy = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[22], 8), imustr[21]))) / wrpyGain
accGain = 5000
imu.ax = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[24], 8), imustr[23]))) / accGain
imu.ay = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[26], 8), imustr[25]))) / accGain
imu.az = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(imustr[28], 8), imustr[27]))) / accGain
return imu;
end
function extractMag(magstr, len)
local mag = {}
mag.type = 'mag'
mag.id = tonumber(ffi.new("double", magstr[5]))
mag.tuc = tonumber(ffi.new("uint32_t", bit.bor(bit.lshift(magstr[9], 24),
bit.lshift(magstr[8], 16), bit.lshift(magstr[7], 8), magstr[6])))
mag.press = tonumber(ffi.new('int16_t', bit.bor(bit.lshift(magstr[11], 8), magstr[10]))) + 100000
mag.temp = tonumber(ffi.new('int16_t', bit.bor(bit.lshift(magstr[15], 8), magstr[14]))) / 100
mag.x = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(magstr[19], 8), magstr[18])))
mag.y = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(magstr[21], 8), magstr[20])))
mag.z = tonumber(ffi.new("int16_t", bit.bor(bit.lshift(magstr[23], 8), magstr[22])))
return mag;
end
function extractGPS(gpsstr, len)
local gps = {}
gps.type = 'gps'
gps.line = str
return gps
end
function pcdata(cdata, size)
str = ''
for i = 0, size - 1 do
str = str..' '..cdata[i]
end
print(str)
end
-- Create files
filecnt = 0;
filetime = utime();
filename = string.format("log-%s-%d", filetime, filecnt);
file = io.open(filename, "w");
linecount = 0;
maxlinecount = 500;
while (1) do
packet, size = ReceivePacket();
if (type(packet) == 'userdata') then
local rawdata = ffi.cast('uint8_t*', packet)
local timestamp = utime()
local data = nil
if rawdata[2] == 0 then
if rawdata[4] == 31 then
str = cdata2gpsstring(rawdata, size)
data = extractGPS(str, #str)
data.timestamp = timestamp
elseif rawdata[4] == 34 then
data = extractImu(rawdata, size)
data.timestamp = timestamp
elseif rawdata[4] == 35 then
data = extractMag(rawdata, size)
data.timestamp = timestamp
end
if data then
savedata = serialization.serialize(data)
file:write(savedata)
file:write('\n')
print(linecount, savedata)
linecount = linecount + 1
end
end
end
if linecount >= maxlinecount then
linecount = 0;
file:close();
filecnt = filecnt + 1;
filename = string.format("log-%s-%d", filetime, filecnt);
file = io.open(filename, "w");
end
end
file:close();
|
slot0 = class("AttireFramePanel", import("...base.BaseSubView"))
slot0.Card = function (slot0)
function slot2(slot0)
slot0._go = slot0
slot0._tf = tf(slot0)
slot0.mark = slot0._tf:Find("info/mark")
slot0.print5 = slot0._tf:Find("prints/line5")
slot0.print6 = slot0._tf:Find("prints/line6")
slot0.emptyTF = slot0._tf:Find("empty")
slot0.infoTF = slot0._tf:Find("info")
slot0.tags = {
slot0._tf:Find("info/tags/e"),
slot0._tf:Find("info/tags/new")
}
slot0.icon = slot0._tf:Find("info/icon")
slot0.mask = slot0._tf:Find("info/mask")
end
function slot3(slot0, slot1, slot2)
slot0.state = slot1:getState()
_.each(slot0.tags, function (slot0)
setActive(slot0, false)
end)
setActive(slot0.mask, slot0.state == AttireFrame.STATE_LOCK)
setActive(slot0.tags[1], slot0.state == AttireFrame.STATE_UNLOCK and slot2.getAttireByType(slot2, slot1:getType()) == slot1.id)
setActive(slot0.tags[2], slot0.state == AttireFrame.STATE_UNLOCK and slot1:isNew())
end
slot2({
isEmpty = function (slot0)
return not slot0.attireFrame or slot0.attireFrame.id == -1
end,
Update = function (slot0, slot1, slot2, slot3)
slot0:UpdateSelected(false)
slot0.attireFrame = slot1
if not slot0:isEmpty() then
slot0(slot0, slot1, slot2)
end
setActive(slot0.infoTF, not slot4)
setActive(slot0.emptyTF, slot4)
setActive(slot0.print5, not slot3)
setActive(slot0.print6, not slot3)
end,
LoadPrefab = function (slot0, slot1, slot2)
slot3 = slot1:getType()
PoolMgr.GetInstance():GetPrefab(slot1:getIcon(), slot1:getPrefabName(), true, function (slot0)
if not slot0.icon then
if nil == AttireConst.TYPE_ICON_FRAME then
slot1 = IconFrame.GetIcon(IconFrame.GetIcon)
elseif slot1 == AttireConst.TYPE_CHAT_FRAME then
slot1 = ChatFrame.GetIcon(ChatFrame.GetIcon)
end
PoolMgr.GetInstance():ReturnPrefab(slot1, PoolMgr.GetInstance().ReturnPrefab, slot0)
else
slot0.name = slot2
setParent(slot0, slot0.icon, false)
slot2 = slot3:getState() == AttireFrame.STATE_LOCK
slot4(slot0)
end
end)
end,
ReturnIconFrame = function (slot0, slot1)
eachChild(slot0.icon, function (slot0)
slot1 = slot0.gameObject.name
slot2 = nil
if slot0 == AttireConst.TYPE_ICON_FRAME then
slot2 = IconFrame.GetIcon(slot1)
elseif slot0 == AttireConst.TYPE_CHAT_FRAME then
slot2 = ChatFrame.GetIcon(slot1)
end
PoolMgr.GetInstance():ReturnPrefab(slot2, slot1, slot0.gameObject)
end)
end,
UpdateSelected = function (slot0, slot1)
setActive(slot0.mark, slot1)
end,
Dispose = function (slot0)
return
end
})
return
end
slot0.getUIName = function (slot0)
return
end
slot0.GetData = function (slot0)
return
end
slot0.OnInit = function (slot0)
slot0.listPanel = slot0:findTF("list_panel")
slot0.scolrect = slot0:findTF("scrollrect", slot0.listPanel):GetComponent("LScrollRect")
slot0.scolrect.onInitItem = function (slot0)
slot0:OnInitItem(slot0)
end
slot0.scolrect.onUpdateItem = function (slot0, slot1)
slot0:OnUpdateItem(slot0, slot1)
end
slot0.cards = {}
slot0.descPanel = AttireDescPanel.New(slot1)
slot0.totalCount = slot0:findTF("total_count/Text"):GetComponent(typeof(Text))
end
slot0.OnInitItem = function (slot0, slot1)
return
end
slot0.OnUpdateItem = function (slot0, slot1, slot2)
if not slot0.cards[slot2] then
slot0:OnInitItem(slot2)
slot3 = slot0.cards[slot2]
end
slot3:Update(slot0.displayVOs[slot1 + 1], slot0.playerVO, slot1 < slot0.scolrect.content:GetComponent(typeof(GridLayoutGroup)).constraintCount)
end
slot0.Update = function (slot0, slot1, slot2)
slot0.playerVO = slot2
slot0.rawAttireVOs = slot1
slot0.displayVOs, ownedCnt = slot0:GetDisplayVOs()
slot0:Filter()
slot0.totalCount.text = ownedCnt
end
slot0.GetDisplayVOs = function (slot0)
slot1 = {}
slot2 = 0
for slot6, slot7 in pairs(slot0:GetData()) do
table.insert(slot1, slot7)
if slot7:getState() == AttireFrame.STATE_UNLOCK and slot7.id > 0 then
slot2 = slot2 + 1
end
end
return slot1, slot2
end
slot0.Filter = function (slot0)
if #slot0.displayVOs == 0 then
return
end
slot1 = slot0.playerVO:getAttireByType(slot0.displayVOs[1]:getType())
table.sort(slot0.displayVOs, function (slot0, slot1)
slot2 = (slot0 == slot0.id and 1) or 0
slot3 = (slot0 == slot1.id and 1) or 0
if slot2 == 1 then
return true
elseif slot3 == 1 then
return false
end
if slot0:getState() == slot1:getState() then
return slot0.id < slot1.id
else
return slot5 < slot4
end
end)
if slot0.scolrect.content.GetComponent(slot2, typeof(GridLayoutGroup)).constraintCount - #slot0.displayVOs % slot0.scolrect.content.GetComponent(slot2, typeof(GridLayoutGroup)).constraintCount == slot0.scolrect.content.GetComponent(slot2, typeof(GridLayoutGroup)).constraintCount then
slot4 = 0
end
if slot3 * slot0:GetColumn() > #slot0.displayVOs then
slot4 = slot5 - #slot0.displayVOs
end
for slot9 = 1, slot4, 1 do
table.insert(slot0.displayVOs, {
id = -1
})
end
slot0.scolrect:SetTotalCount(#slot0.displayVOs, -1)
end
slot0.UpdateDesc = function (slot0, slot1)
if slot1:isEmpty() then
return
end
if not slot0.descPanel then
slot0.descPanel = AttireDescPanel.New(slot0.descPanelTF)
end
slot0.descPanel:Update(slot1.attireFrame, slot0.playerVO)
onButton(slot0, slot0.descPanel.applyBtn, function ()
slot0.attireFrame:emit(AttireMediator.ON_APPLY, slot0.attireFrame:getType(), slot0.attireFrame.id)
end, SFX_PANEL)
end
slot0.OnDestroy = function (slot0)
slot0.descPanel:Dispose()
end
return slot0
|
local api = require('vfiler/actions/api')
local core = require('vfiler/libs/core')
local vim = require('vfiler/libs/vim')
local VFiler = require('vfiler/vfiler')
local M = {}
------------------------------------------------------------------------------
-- Control buffer
------------------------------------------------------------------------------
function M.quit(vfiler, context, view)
api.close_preview(vfiler, context, view)
vfiler:quit()
end
function M.quit_force(vfiler, context, view)
api.close_preview(vfiler, context, view)
vfiler:quit(true)
end
function M.redraw(vfiler, context, view)
view:redraw()
end
function M.reload(vfiler, context, view)
context:save(view:get_item().path)
context:reload()
view:draw(context)
end
function M.reload_all(vfiler, context, view)
VFiler.foreach(M.reload)
end
function M.switch_to_filer(vfiler, context, view)
-- only window style
if view:type() ~= 'window' then
return
end
-- close preview window
api.close_preview(vfiler, context, view)
local linked = context.linked
-- already linked
if linked then
if linked:visible() then
linked:focus()
else
linked:open('right')
end
linked:do_action(api.open_preview)
return
end
-- create link to filer
local lnum = vim.fn.line('.')
local newfiler = vfiler:copy()
newfiler:open('right')
newfiler:link(vfiler)
newfiler:start(context.root.path)
core.cursor.move(lnum)
-- redraw current
vfiler:focus()
view:draw(context)
newfiler:focus() -- return other filer
newfiler:do_action(api.open_preview)
end
function M.sync_with_current_filer(vfiler, context, view)
local linked = context.linked
if not (linked and linked:visible()) then
return
end
linked:focus()
linked:update(context)
linked:do_action(api.cd, context.root.path)
vfiler:focus() -- return current window
end
return M
|
require('tree')
local lu = require('luaunit')
local function get_children(leaves, nodes)
local children = {}
local leaf_ctr = 1
nodes = nodes or 0
for i = 1, leaves + nodes do
if leaf_ctr <= leaves then
children[i] = Leaf:new()
leaf_ctr = leaf_ctr + 1
else
children[i] = Node:new()
end
end
return children
end
function TestRootAddChild()
local root = Root:new()
local leaf = Leaf:new()
root:add_child(leaf)
assert(root.children[1] == leaf)
end
function TestRootAddChildren()
local root = Root:new()
local children = get_children(2, 1)
root:add_children(children)
assert(#root.children == 3)
end
function TestNodeAddChildren()
local node = Node:new()
local children = get_children(2, 1)
node:add_children(children)
assert(#node.children == 3)
end
function TestNodeAddItselfAsChild()
local node = Node:new()
lu.assertError(node.add_child, node, child)
end
--- Behavioural tests
function TestNodeFromChildren()
local root = Root:new()
local children = get_children(10)
root:add_children(children)
assert(
#root.children == 10,
('should be 1. found %s'):format(#root.children)
)
local node = Node:new_from_children(children)
assert(
#root.children == 1,
('should be 1. found %s'):format(#root.children)
)
assert(table.unpack(root.children) == node)
assert(#node.children == 10)
assert(node.parent == root)
end
function TestMoveChildrenToNode()
local root = Root:new()
local children = get_children(10)
root:add_children(children)
assert(
#root.children == 10,
('should be 1. found %s'):format(#root.children)
)
local node1 = Node:new_from_children(children)
assert(
#root.children == 1,
('should be 1. found %s'):format(#root.children)
)
assert(table.unpack(root.children) == node1)
assert(#node1.children == 10)
assert(node1.parent == root)
local function get_odd_children()
local odd_children = {}
for i, child in ipairs(node1.children) do
if i % 2 ~= 0 then
odd_children[#odd_children + 1] = child
end
end
return odd_children
end
local node2 = Node:new()
node1:move_children_to(get_odd_children(), node2)
assert(
#node1.children == 5,
('node 1 children should be 5. Found %s'):format(#node1.children)
)
assert(
#node2.children == 5, (
'node 2 children should be 5. Found %s'):format(#node2.children)
)
assert(
node1.parent == root,
('node 1 parent should be root. Found %s'):format(node1.parent)
)
assert(
node2.parent == root,
('node 2 parent should be root. Found %s'):format(node2.parent)
)
assert(
root.children[1] == node1,
('Child 1 should be node 1. Found %s'):format(root.children[1])
)
assert(
root.children[1] == node1,
('Child 2 should be node 2. Found %s'):format(root.children[2])
)
end
local runner = lu.LuaUnit.new()
runner:setOutputType("text")
os.exit( runner:runSuite() )
--
--node1 = Node:new_from_children(root.children)
--print('root children after moving to node 1')
--for child in root:iter_children() do
-- print(child)
--end
--print('should be the new node 1\n')
--
--print('node 1 children after init')
--for child in node1:iter_children() do
-- print(child)
--end
--print('should be all previous root children\n')
--
--node2 = Node:new(root)
--print('new node 2 ' .. tostring(node2))
--print('node 2 children after init')
--for child in node2:iter_children() do
-- print(child)
--end
--print('should be none\n')
--
--local odd_children = {}
--for i, c in pairs(node1.children) do
-- if i % 2 ~= 0 then
-- odd_children[#odd_children + 1] = c
-- end
--end
--
--node1:move_children_to(odd_children, node2)
--print('node 1 children after moving to node 2')
--for child in node1:iter_children() do
-- print(child)
--end
--print('\n')
--
--print('node 2 children after moving')
--for child in node2:iter_children() do
-- print(child)
--end
--print('\n')
--
--print('root children after moving children from node 1 to node 2')
--for child in root:iter_children() do
-- print(child)
--end
--print('Should be node 1 and node 2\n')
--
--local node3 = root:add_node()
--node3:add_leaves(10)
--local subnode3 = node3:add_node()
--subnode3:add_leaves(10)
--
--
--
--print('root children after adding node 3')
--for child in root:iter_children() do
-- print(child)
--end
--print('Should be node 1, node 2 and node 3 \n')
--
--print('tree traversal')
--
--spaces = ' '
--prev_level = 0
--for child, level in traverse_tree(root.children) do
-- separator = string.rep(spaces, level)
-- print(separator .. tostring(child))
--end |
-- Inspiration from tjdevries
-- https://github.com/tjdevries/config_manager/blob/master/xdg_config/nvim/lua/tj/first_load.lua
local empty = require("blaz.helper.vim").empty
local data_dir = string.format("%s/site", vim.fn.stdpath("data"))
local function download_vim_plug()
local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
local cmd_str = string.format(
"curl -fLo %s/autoload/plug.vim --create-dirs %s",
data_dir,
plug_download_url
)
print(cmd_str)
local out = vim.fn.system(cmd_str)
print(out)
print("(Downloading Vim-Plug...)")
vim.api.nvim_create_autocmd("VimEnter", {
pattern = "*",
command = [[PlugInstall --sync | execute "source" stdpath("config") . '/init.lua']],
})
end
---@module "blaz.plugins"
local M = {}
-- TODO replace vim-plug with Packer
---Load Neovim plugins
---@param plugin_download_dir string directory to store downloaded plugins
M.load = function(plugin_download_dir)
plugin_download_dir = plugin_download_dir or vim.fn.stdpath("data") .. "/plugged"
-- Perform interstitial safeguard check for Vim-Plug
-- Adapted from https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
if empty(vim.fn.glob(data_dir .. "/autoload/plug.vim")) then
download_vim_plug()
end
---@param plugin string
---@param opts_str string
local function Plug(plugin, opts_str)
if type(plugin) ~= "string" then
return
end
local cmd_str = (opts_str == nil or opts_str == "") and string.format([[Plug '%s']], plugin)
or string.format([[Plug '%s', %s]], plugin, opts_str)
vim.cmd(cmd_str)
end
vim.fn["plug#begin"](plugin_download_dir)
Plug("windwp/nvim-autopairs")
Plug("ellisonleao/gruvbox.nvim")
Plug("folke/tokyonight.nvim", "{ 'branch': 'main' }")
Plug("projekt0n/github-nvim-theme")
Plug("preservim/nerdcommenter")
Plug("neovim/nvim-lspconfig")
Plug("williamboman/nvim-lsp-installer")
Plug("jose-elias-alvarez/null-ls.nvim")
Plug("simrat39/rust-tools.nvim")
Plug("rust-lang/rust.vim")
Plug("mfussenegger/nvim-jdtls")
Plug("hrsh7th/cmp-nvim-lsp")
Plug("hrsh7th/cmp-nvim-lsp-document-symbol")
Plug("saadparwaiz1/cmp_luasnip")
Plug("hrsh7th/cmp-nvim-lua")
Plug("hrsh7th/cmp-buffer")
Plug("hrsh7th/cmp-path")
Plug("hrsh7th/cmp-cmdline")
Plug("hrsh7th/nvim-cmp")
Plug("onsails/lspkind-nvim")
-- nvim-cmp requires a snippet engine
Plug("L3MON4D3/LuaSnip")
Plug("lewis6991/gitsigns.nvim")
Plug("tpope/vim-fugitive")
Plug("kyazdani42/nvim-web-devicons") -- for file icons
Plug("kyazdani42/nvim-tree.lua")
Plug("nvim-lualine/lualine.nvim")
Plug("nvim-lua/popup.nvim")
Plug("nvim-lua/plenary.nvim")
Plug("nvim-telescope/telescope.nvim")
Plug("nvim-telescope/telescope-fzy-native.nvim")
Plug("nvim-telescope/telescope-ui-select.nvim")
Plug("nvim-treesitter/nvim-treesitter", "{ 'do': ':TSUpdate' }")
Plug("rcarriga/nvim-notify")
-- `plug#end` automatically executes `filetype plugin indent on` and `syntax enable`
vim.fn["plug#end"]()
-- vim.cmd("doautocmd User PlugLoaded")
end
return M
|
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- Multiplayer lobby
gVoiceIconSpeaker = gXLFriendsEnum2UVs[7]
gVoiceIconTalking = gXLFriendsEnum2UVs[10]
gVoiceIconMuted = gXLFriendsEnum2UVs[8]
gVoiceIconTV = gXLFriendsEnum2UVs[9]
--
-- voice status icons
gVoiceStatus =
{
send =
{
{ alpha = 1.0, UVs = gVoiceIconMuted, flash = nil }, -- send disabled
{ alpha = 0.8, UVs = gVoiceIconSpeaker, flash = 1 }, -- send disabled, remote receive enabled
{ alpha = 0.4, UVs = gVoiceIconSpeaker, flash = nil }, -- send enabled
{ alpha = 1.0, UVs = gVoiceIconSpeaker, flash = nil }, -- send possible
{ alpha = 1.0, UVs = gVoiceIconTalking, flash = nil }, -- sending
{ alpha = 1.0, UVs = gVoiceIconTV, flash = nil }, -- send possible / sending to TV
},
receive =
{
{ alpha = 1.0, UVs = gVoiceIconMuted, flash = nil }, -- receive disabled
{ alpha = 0.8, UVs = gVoiceIconSpeaker, flash = 1 }, -- receive disabled, remote send enabled
{ alpha = 0.4, UVs = gVoiceIconSpeaker, flash = nil }, -- receive enabled
{ alpha = 1.0, UVs = gVoiceIconSpeaker, flash = nil }, -- receive possible
{ alpha = 1.0, UVs = gVoiceIconTalking, flash = nil }, -- receiving
{ alpha = 1.0, UVs = gVoiceIconTV, flash = nil }, -- receive possible / receiving to TV
}
}
-- Helper function. Given a layout (x,y,width, height), returns a
-- fully-built item.
function ifs_mp_lobby_Listbox_CreateItem(layout)
-- Make a coordinate system pegged to the top-left of where the cursor would go.
local Temp = NewIFContainer { x = layout.x - 0.5 * layout.width, y = layout.y}
-- SM 8-Feb-05 all column widths are now relative to the width of the list box
local BorderWidth = 10 -- should be subtracted from the first and
-- last column widths
local NameWidth = layout.width * 0.5
local TeamWidth = layout.width * 0.2
local KillsWidth = layout.width * 0.1
local PingWidth = layout.width * 0.11
local QOSWidth = layout.width * 0.2
local XLiveStatusWidth = layout.width * 0.05
local VoiceWidth = layout.width * 0.05
local VoiceSendWidth = layout.width * 0.13
local VoiceReceiveWidth = layout.width * 0.12
local y_offset = 4
-- SM 8-Feb-05 not sure what this has to do with idiot mode
-- (bars instead of numbers for ping)
-- if a column doesn't need to be displayed then just set its width to 0
-- and it will not be created
-- futhermore, I disabled the ability to toggle idiot mode on and off
-- it requires a significant amount of real estate to display the
-- "connection" header for the QOS field
if (not ifs_mp_lobby.bIdiotMode) then
QOSWidth = 0
else
PingWidth = 0
end
if (gPlatformStr ~= "PC") then
KillsWidth = 0
end
-- Removed voice columns NM 9/19/05, per bug 13422
if ((gOnlineServiceStr == "XLive") or (gPlatformStr == "PC")) then
VoiceSendWidth = 0
VoiceReceiveWidth = 0
VoiceWidth = VoiceWidth + BorderWidth
else
XLiveStatusWidth = 0
VoiceWidth = 0
VoiceReceiveWidth = VoiceReceiveWidth + BorderWidth
end
-- SM 7-Feb-05 I decided to right align all fields with the exception
-- of the name field
local NamePos = BorderWidth
local VoiceReceivePos = layout.width - VoiceReceiveWidth
local VoiceSendPos = VoiceReceivePos - VoiceSendWidth
local VoicePos = VoiceSendPos - VoiceWidth -- XLive voice status icon
local PingPos = VoicePos - PingWidth
local QOSPos = VoicePos - QOSWidth -- XLive ping / quality of service icon
local XLiveStatusPos = QOSPos - XLiveStatusWidth
local KillsPos = math.min(PingPos, QOSPos) - KillsWidth
local TeamPos = KillsPos - TeamWidth
-- clamp name width to the actually displayed value
NameWidth = TeamPos - NamePos
local QOSHeight = 0.8 * layout.height -- height of ping bar
local IconSize = 0.9 * layout.height -- size of each icon in lobby_icons.tga
local fontLocal
-- SM 8-Feb-05 only use big font when idiot mode is disabled or
-- on PS2 where the resolution is poopy
if (layout.bTitles and
((gPlatformStr == "XBox") or (gPlatformStr == "PS2"))) then
fontLocal = "meu_myriadpro_small" -- big(ish) font for column headers
else
fontLocal = "meu_myriadpro_small" -- smaller font for contents
end
if (NameWidth > 0) then
Temp.namefield = NewIFText{
x = NamePos, y = -10 + y_offset, textw = NameWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (TeamWidth > 0) then
Temp.teamfield = NewIFText{
x = TeamPos, y = -10 + y_offset, textw = TeamWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (KillsWidth > 0) then
Temp.killsfield = NewIFText{
x = KillsPos, y = -10 + y_offset, textw = KillsWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
if (PingWidth > 0) then
Temp.pingfield = NewIFText{
x = PingPos, y = -10 + y_offset, textw = PingWidth,
halign = "left", font = fontLocal, nocreatebackground=1,
inert_all = 1,
}
end
-- if the titles of the list box are being created
if (layout.bTitles) then
if (QOSWidth > 0) then
-- XLive requires ping / quality of service to be displayed as a status bar
Temp.qosfield = NewIFText{
x = QOSPos, y = -10 + y_offset, textw = QOSWidth,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
-- seperate send / receive status
if (VoiceSendWidth > 0) then
Temp.voiceSendField = NewIFText{
x = VoiceSendPos, y = -10 + y_offset, textw = VoiceWidth,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
if (VoiceReceiveWidth > 0) then
Temp.voiceReceiveField = NewIFText{
x = VoiceReceivePos, y = -10 + y_offset, textw = 120,
halign = "left", font = fontLocal, nocreatebackground = 1,
inert_all = 1,
}
end
else
if (QOSWidth > 0) then
-- XLive requires ping / quality of service to be displayed as a
-- status bar
Temp.qosfield = NewIFImage{
x = QOSPos, y = 6 + y_offset, -- y-pos is to get it centered in bar
texture = "ping_icon",
localpos_l = 0, localpos_t = -13,
localpos_b = QOSHeight - 10 - 7, localpos_r = 40,
}
end
local VoiceIconYOffset = 14
-- XLive friend state
if (XLiveStatusWidth > 0) then
Temp.StateIcon = NewIFImage{
x = XLiveStatusPos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceWidth > 0) then
-- XLive requires certain icons for voice status which means the
-- muted (send + receive enabled) status is hidden to other players
-- the local player only knows who is locally muted
Temp.VoiceIcon = NewIFImage {
x = VoicePos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceSendWidth > 0) then
-- seperate send / receive status
Temp.voiceSendField = NewIFImage {
x = VoiceSendPos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
if (VoiceReceiveWidth > 0) then
Temp.voiceReceiveField = NewIFImage {
x = VoiceReceivePos, y = 3 + y_offset, -- y-pos is to get it centered in bar
texture = "lobby_icons",
localpos_l = 0, localpos_t = -VoiceIconYOffset,
localpos_b = IconSize - VoiceIconYOffset, localpos_r = IconSize,
bInertPos = 1, inert_all = 1,
}
end
end
return Temp
end
-- display a voice icon
function ifs_mp_lobby_Listbox_DisplayVoiceIcon(field, iconInfo, flashAlpha)
local UVs
local alpha
UVs = iconInfo.UVs
alpha = iconInfo.alpha
if (iconInfo.flash) then
alpha = alpha * flashAlpha
end
IFImage_fnSetUVs(field, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
IFObj_fnSetAlpha(field, alpha)
IFObj_fnSetVis (field, 1)
end
-- Helper function. For a destination item (previously created w/
-- CreateItem), fills it in with data, which may be nil (==blank it)
function ifs_mp_lobby_Listbox_PopulateItem(Dest, Data, bSelected, ColorR, ColorG, ColorB, fAlpha)
-- If we need to zap the glyphcache, do so.
if (gBlankListbox) then
if (Dest.namefield) then
IFText_fnSetString(Dest.namefield, "")
end
if (Dest.teamfield) then
IFText_fnSetString(Dest.teamfield, "")
end
if (Dest.pingfield) then
IFText_fnSetString(Dest.pingfield, "")
end
if (Dest.killsfield) then
IFText_fnSetString(Dest.killsfield," ")
end
elseif (Data) then
-- Have data, time to draw. Do so.
if (Dest.namefield) then
IFObj_fnSetColor(Dest.namefield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.namefield, fAlpha)
end
if (Dest.teamfield) then
IFObj_fnSetColor(Dest.teamfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.teamfield, fAlpha)
end
if (Dest.pingfield) then
IFObj_fnSetColor(Dest.pingfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.pingfield, fAlpha)
end
if (Dest.killsfield) then
IFObj_fnSetColor(Dest.killsfield, ColorR, ColorG, ColorB)
IFObj_fnSetAlpha(Dest.killsfield, fAlpha)
end
-- name
if (Dest.namefield) then
IFText_fnSetString(Dest.namefield, Data.namestr)
--IFText_fnSetString(Dest.namefield,"WWWWWWWWWWWWWWM") -- space test
end
-- team
if (Dest.teamfield) then
if (Data.iTeam < 0.5) then
IFText_fnSetUString(Dest.teamfield, ScriptCB_GetTeamName(1))
else
IFText_fnSetUString(Dest.teamfield, ScriptCB_GetTeamName(2))
end
if (Data.ColorR) then
IFObj_fnSetColor(Dest.teamfield, Data.ColorR, Data.ColorG, Data.ColorB)
end
end
-- ping / quality of service
if (Dest.qosfield) then
local U1 = (5 - Data.iQOS) * 0.2
IFImage_fnSetUVs(Dest.qosfield, U1, 0.0, U1 + 0.2, 1.0)
elseif (Dest.pingfield) then
IFText_fnSetString(Dest.pingfield, Data.pingstr)
end
if (Dest.killsfield) then
IFText_fnSetString(Dest.killsfield, Data.killsstr)
end
-- update XLive friend state icon
if(Data.StateIcon) then
local UVs = gXLFriendsEnum2UVs[Data.StateIcon + 1] -- lua counts from 1
IFImage_fnSetUVs(Dest.StateIcon, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
end
if (Dest.StateIcon) then
IFObj_fnSetVis(Dest.StateIcon, Data.StateIcon)
end
-- update XLive voice icon
if (Data.VoiceIcon) then
local UVs = gXLFriendsEnum2UVs[Data.VoiceIcon + 1] -- lua counts from 1
IFImage_fnSetUVs(Dest.VoiceIcon, UVs.u, UVs.v, UVs.u + 0.25, UVs.v + 0.25)
IFObj_fnSetAlpha(Dest.VoiceIcon, Data.VoiceIconAlpha)
end
if (Dest.VoiceIcon) then
IFObj_fnSetVis(Dest.VoiceIcon, Data.VoiceIcon)
end
-- voice send / receive states
if (Dest.voiceSendField and Dest.voiceReceiveField) then
local sendStatus = ScriptCB_GetVoiceSendStatus(Data.indexstr)
local receiveStatus = ScriptCB_GetVoiceReceiveStatus(Data.indexstr)
local iconInfo
local flashAlpha = ((math.min(ifs_mp_lobby.flashNextTime - ifs_mp_lobby.flashTimeElapsed, 1.0)) /
ifs_mp_lobby.flashInterval)
-- flash on or off as the update rate is really slow
if (flashAlpha > 0.5) then
flashAlpha = 1.0
else
flashAlpha = 0
end
if (sendStatus > 0) then
ifs_mp_lobby_Listbox_DisplayVoiceIcon(Dest.voiceSendField, gVoiceStatus.send[sendStatus], flashAlpha)
else
IFObj_fnSetVis(Dest.voiceSendField, nil)
end
if (receiveStatus > 0) then
ifs_mp_lobby_Listbox_DisplayVoiceIcon(Dest.voiceReceiveField, gVoiceStatus.receive[receiveStatus], flashAlpha)
else
IFObj_fnSetVis(Dest.voiceReceiveField, nil)
end
end
end -- Data exists
-- Show entry if Data != nil
IFObj_fnSetVis(Dest,Data)
end
lobby_listbox_layout = {
showcount = 10,
-- yTop = -130 + 13, -- auto-calc'd now
yHeight = 26,
ySpacing = 0,
width = 430,
x = 0,
slider = 1,
CreateFn = ifs_mp_lobby_Listbox_CreateItem,
PopulateFn = ifs_mp_lobby_Listbox_PopulateItem,
}
ifs_mp_lobby_listbox_contents = {
-- Filled in from C++ now. NM 8/7/03
-- Stubbed to show the string.format it wants.
-- { indexstr = "1", namestr = "Alpha"},
-- { indexstr = "2", namestr = "Bravo"},
}
-- Callbacks from the busy popup
-- Returns -1, 0, or 1, depending on error, busy, or success
function ifs_mplobby_leavepopup_fnCheckDone()
-- local this = ifs_sessionlist_joinpopup
ScriptCB_UpdateLeave() -- think...
return ScriptCB_IsLeaveDone()
end
function ifs_mplobby_leavepopup_fnOnSuccess()
local this = ifs_mp_lobby
Popup_Busy:fnActivate(nil)
ifs_mp_lobby_fnShowHideItems(this, 1)
ScriptCB_PopScreen("ifs_mp_main")
end
function ifs_mplobby_leavepopup_fnOnFail()
-- This shouldn't happen, but go back in any case
local this = ifs_mp_lobby
Popup_Busy:fnActivate(nil)
ifs_mp_lobby_fnShowHideItems(this, 1)
ScriptCB_PopScreen("ifs_mp_main")
end
function ifs_mplobby_leavepopup_fnOnCancel()
-- Shouldn't happen!
ifs_mp_lobby_fnShowHideItems(this, 1)
end
-- Callback after the "really leave session?" popup is done.
-- If bResult is true, then the user hit yes, else no.
function ifs_mp_lobby_fnLeavePopupDone(bResult)
local this = ifs_mp_lobby
if(bResult) then
-- User does want to leave. Start the process.
ScriptCB_BeginLeave()
-- And show the popup.
Popup_Busy.fnCheckDone = ifs_mplobby_leavepopup_fnCheckDone
Popup_Busy.fnOnSuccess = ifs_mplobby_leavepopup_fnOnSuccess
Popup_Busy.fnOnFail = ifs_mplobby_leavepopup_fnOnFail
Popup_Busy.fnOnCancel = ifs_mplobby_leavepopup_fnOnCancel
Popup_Busy.bNoCancel = 1 -- no cancel button
Popup_Busy.fTimeout = 5 -- seconds
IFText_fnSetString(Popup_Busy.title,"common.mp.leaving")
Popup_Busy:fnActivate(1)
else
ifs_mp_lobby_fnShowHideItems(this,1)
end
end
-- callback when the lobby options popup is done
function ifs_mp_lobby_fnLobbyOptionsPopupDone()
local this = ifs_mp_lobby
-- force a reget of the listbox to update any changes
ifs_mp_lobby_SetHilight(this,lobby_listbox_layout.SelectedIdx)
end
-- Helper function: turns pieces on/off as requested
function ifs_mp_lobby_fnShowHideItems(this,bNormalVis)
IFObj_fnSetVis(this.listbox,bNormalVis)
IFObj_fnSetVis(this.columnheaders,bNormalVis)
-- IFObj_fnSetVis(this.buttons,bNormalVis and this.bShellActive)
end
-- Sets the hilight on the listbox, create button given a hilight
function ifs_mp_lobby_SetHilight(this,aListIndex)
lobby_listbox_layout.SelectedIdx = aListIndex
if(gPlatformStr ~= "PC") then
lobby_listbox_layout.CursorIdx = aListIndex
end
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_DoTestCanBoot( selected_idx, force_boot )
local this = ifs_mp_lobby
if (not force_boot) then
-- default to visible
local BootVisible = 1
if(selected_idx) then
-- the currently selected player
local Selection = ifs_mp_lobby_listbox_contents[selected_idx]
if(not Selection) then
return nil
end
local bIsMe = Selection.bIsLocal
local muted,friend,bCanBoot,bIsGuest,bCanAddFriend = ScriptCB_GetLobbyPlayerFlags(Selection.namestr, Selection.indexstr)
--print( "++++1++++bIsMe = ", bIsMe, " bCanBoot = ", bCanBoot, " BootVisible = ", BootVisible, " Selection.indexstr =", Selection.indexstr )
if(ScriptCB_GetAmHost()) then
BootVisible = nil -- bugs # 14579, 145780
-- don't let host "vote to boot" as he has the option to force boot
else
-- Not host. Set client options
BootVisible = not ScriptCB_IsInShell()
if( bIsMe ) then
BootVisible = nil -- can't kick self
end
-- won't boot if players are different team
local NumEntries = table.getn(ifs_mp_lobby_listbox_contents)
local bIsSameTeam = nil
for i = 1, NumEntries do
if( ifs_mp_lobby_listbox_contents[i].bIsLocal and
Selection.iTeam == ifs_mp_lobby_listbox_contents[i].iTeam ) then
bIsSameTeam = 1
end
end
if( not bIsSameTeam ) then
BootVisible = nil
end
end
--print( "++++2++++BootVisible = ", BootVisible )
-- global can you boot this person?
if(not bCanBoot) then
BootVisible = nil
end
else
-- nobody home, hidden
BootVisible = nil
end
--print( "++++3++++BootVisible = ", BootVisible )
return BootVisible
else
-- default to invisible
local ForceBootVisible = nil
if(lobby_listbox_layout.SelectedIdx) then
-- the currently selected player
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
ForceBootVisible = nil
else
local bIsMe = Selection.bIsLocal
if(ScriptCB_GetAmHost()) then
ForceBootVisible = not bIsMe -- can't kick self
else
ForceBootVisible = nil
end
end
else
-- nobody home, hidden
ForceBootVisible = nil
end
return ForceBootVisible
end
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_CalcCanBoot()
local this = ifs_mp_lobby
this.BootVisible = ifs_mp_lobby_DoTestCanBoot( lobby_listbox_layout.SelectedIdx, nil )
-- show/hide the boot button
IFObj_fnSetVis(this.Helptext_Misc,this.BootVisible)
end
-- this recalculates the boot flag and the vote button visibility
function ifs_mp_lobby_CalcCanForceBoot()
local this = ifs_mp_lobby
this.ForceBootVisible = ifs_mp_lobby_DoTestCanBoot( lobby_listbox_layout.SelectedIdx, true )
-- show/hide the boot button
IFObj_fnSetVis(this.Helptext_ForceBoot,this.ForceBootVisible)
if(this.ForceBootVisible) then
if (this.Helptext_ForceBoot.helpstr) then
IFText_fnSetString(this.Helptext_ForceBoot.helpstr, "ifs.onlinelobby.forceboot")
end
end
end
-- bringup vote to boot popup
function ifs_mp_lobby_DoPopupVootBoot( force_boot )
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
Popup_Vote.CurButton = "no" -- default
Popup_Vote.SelectedIdx = lobby_listbox_layout.SelectedIdx
Popup_Vote.force_boot = force_boot
Popup_Vote:fnActivate(1)
end
function ifs_mp_lobby_IsBandwidthVisible(this)
return nil
--return this.bCanAdjustBW and ScriptCB_GetAmHost() and (gOnlineServiceStr ~= "LAN")
end
function ifs_mp_lobby_UpdateBandwidth(this, value)
IFText_fnSetUString( this.Bandwidth,
ScriptCB_usprintf("ifs.mp.bandwidth",
ScriptCB_tounicode( string.format("%d",value) )))
end
ifs_mp_lobby = NewIFShellScreen {
nologo = 1,
bDimBackdrop = 1,
bg_texture = "iface_bgmeta_space",
flashTimeElapsed = 0.0,
flashNextTime = 0.0,
flashInterval = 1.0,
bIdiotMode = nil,
launchflag = nil,
title = NewIFText {
-- string = "common.mp.lobby",
font = "meu_myriadpro_large",
y = 0,
textw = 460, -- center on screen. Fixme: do real centering!
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0, -- top
nocreatebackground = 1,
},
-- Vote helptext
IPAddr = NewIFText {
-- string = "ifs.mp.connection.title",
font = "meu_myriadpro_small",
textw = 460,
halign = "right",
ScreenRelativeX = 1.0, -- right
ScreenRelativeY = 1.0, -- near bottom
y = -90,
x = -460,
nocreatebackground = 1,
},
ServerName = NewIFText {
-- string = "ifs.mp.connection.title",
font = "meu_myriadpro_small",
textw = 460,
halign = "left",
ScreenRelativeX = 0, -- left
ScreenRelativeY = 1.0, -- near bottom
y = -90,
x = 25,
nocreatebackground = 1,
},
Bandwidth = NewIFText {
font = "meu_myriadpro_small",
textw = 460,
halign = "left",
ScreenRelativeX = 0, -- left
ScreenRelativeY = 1.0, -- near bottom
y = -60,
x = 25,
-- nocreatebackground = 1,
},
Enter = function(this, bFwd)
-- Always call base class
gIFShellScreenTemplate_fnEnter(this, bFwd)
-- gHelptext_fnMoveIcon(this.Helptext_Misc2)
-- Added chunk for error handling...
if(not bFwd) then
local ErrorLevel,ErrorMessage = ScriptCB_GetError()
if(ErrorLevel >= 6) then -- session or login error, must keep going further
ScriptCB_PopScreen()
end
end
this.bCanAdjustBW = not gFinalBuild
this.bShellActive = ScriptCB_GetShellActive()
if(this.Helptext_Accept) then
IFText_fnSetString(this.Helptext_Accept.helpstr,"ifs.onlinelobby.playeropts")
gHelptext_fnMoveIcon(this.Helptext_Accept)
end
if(gPlatformStr == "XBox") then
IFText_fnSetString(this.title, "game.pause.playerlist")
else
this.bAmHost = ScriptCB_GetAmHost()
if(this.bAmHost) then
IFText_fnSetString(this.title, "ifs.mplobby.host_title")
else
IFText_fnSetString(this.title, "ifs.mplobby.client_title")
end
end
-- Reset listbox, show it. [Remember, Lua starts at 1!]
lobby_listbox_layout.FirstShownIdx = 1
lobby_listbox_layout.SelectedIdx = 1
lobby_listbox_layout.CursorIdx = 1
if(bFwd) then
ScriptCB_BeginLobby()
else
-- force an update, NOW. (we zapped everything leaving this screen, gotta
-- restore it on re-entry)
ScriptCB_UpdateLobby(1)
end
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
ifs_mp_lobby_SetHilight(this,1)
ifs_mp_lobby_fnShowHideItems(this,1)
IFText_fnSetString(this.IPAddr,"IP: " .. ScriptCB_GetIPAddr())
IFText_fnSetString(this.ServerName,ScriptCB_GetGameName())
IFObj_fnSetVis(this.IPAddr, (gOnlineServiceStr ~= "XLive") and (not ifs_mp_lobby.bE3Mode) and (not gFinalBuild))
-- Show server name all the time, request from Brad - NM 8/24/05
IFObj_fnSetVis(this.ServerName, 1) -- (gOnlineServiceStr ~= "XLive") and (not ifs_mp_lobby.bE3Mode) and (not gFinalBuild))
-- IFObj_fnSetVis(this.Helptext_Misc2,not ifs_mp_lobby.bE3Mode)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
IFObj_fnSetVis(this.Bandwidth, 1)
ifs_mp_lobby_UpdateBandwidth( this, ScriptCB_GetBandwidth() )
else
IFObj_fnSetVis(this.Bandwidth, nil)
end
if((this.bAutoLaunch) or (this.bHideOnEntry)) then
-- Hide everything ASAP
IFObj_fnSetVis(this.title,nil)
-- IFObj_fnSetVis(this.Helptext_Misc2,nil)
if(this.Helptext_Accept) then
IFObj_fnSetVis(this.Helptext_Accept,nil)
end
if(this.Helptext_Back) then
IFObj_fnSetVis(this.Helptext_Back,nil)
end
IFObj_fnSetVis(this.IPAddr,nil)
IFObj_fnSetVis(this.ServerName,nil)
IFObj_fnSetVis(this.listbox,nil)
IFObj_fnSetVis(this.columnheaders,nil)
this.bHideOnEntry = nil -- clear flag
end
-- set the visibility of the boot button
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Exit = function(this, bFwd)
if(bFwd) then -- going to string.sub-screen
else
ScriptCB_CancelLobby() -- going back to create opts (host) or sessionlist (client)
end
-- Clear out glyph cache
gBlankListbox = 1
if(ifs_mp_lobby_listbox_contents) then
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
gBlankListbox = nil
ifs_mp_lobby_listbox_contents = {} -- clear this from memory also.
end,
Input_Accept = function(this)
if(gShellScreen_fnDefaultInputAccept(this)) then
local bExitNow = 1
if(gMouseListBox) then
if(gMouseListBox.Layout.SelectedIdx == gMouseListBox.Layout.CursorIdx) then
if(this.fDoubleClickTimer < 0.01) then
this.fDoubleClickTimer = 0.4
else
bExitNow = nil
end -- timer
else
-- Selected index changed.
gMouseListBox.Layout.SelectedIdx = gMouseListBox.Layout.CursorIdx
end
end -- gMouseListBox is valid
-- print("mp_lobby. Default accept handled, returning.")
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
if(bExitNow) then
return
end
end
if (this.CurButton == "voteboot") then
-- make sure this is updated
ifs_mp_lobby_CalcCanBoot()
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(this.BootVisible and Selection) then
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "boot")
end
else
if( this.BootVisible) then
ifs_mp_lobby_DoPopupVootBoot( nil )
end
end
-- hide the button, since we just voted
ifs_mp_lobby_CalcCanBoot()
elseif (this.CurButton == "forceboot") then
-- make sure this is updated
ifs_mp_lobby_CalcCanForceBoot()
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(this.ForceBootVisible and Selection) then
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "forceboot")
end
else
if( this.ForceBootVisible ) then
ifs_mp_lobby_DoPopupVootBoot( 1 )
end
end
-- hide the button, since we just voted
ifs_mp_lobby_CalcCanForceBoot()
else -- SM 7-Feb-05 -- if (gPlatformStr ~= "PC") then
if(lobby_listbox_layout.SelectedIdx) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
IFText_fnSetString(Popup_LobbyOpts.title,Selection.namestr)
Popup_LobbyOpts.bIsMe = Selection.bIsLocal and (Selection.iViewport == ScriptCB_GetPausingViewport())
-- print("bIsMe = ", Popup_LobbyOpts.bIsMe, " from ", Selection.bIsLocal, Selection.iViewport ,ScriptCB_GetPausingViewport())
local NumEntries = table.getn(ifs_mp_lobby_listbox_contents)
Popup_LobbyOpts.bIsSameTeam = nil
for i = 1, NumEntries do
--print("+++i=", i, Selection.iTeam, ifs_mp_lobby_listbox_contents[i].bIsLocal, ifs_mp_lobby_listbox_contents[i].namestr, ifs_mp_lobby_listbox_contents[i].iTeam )
if( ifs_mp_lobby_listbox_contents[i].bIsLocal ) then
if( Selection.iTeam == ifs_mp_lobby_listbox_contents[i].iTeam ) then
--print("+++x=", i, Selection.iTeam, ifs_mp_lobby_listbox_contents[i].bIsLocal, ifs_mp_lobby_listbox_contents[i].namestr, ifs_mp_lobby_listbox_contents[i].iTeam )
Popup_LobbyOpts.bIsSameTeam = 1
end
end
end
ifelm_shellscreen_fnPlaySound(this.acceptSound)
-- Get their muted, friend flags.
-- also get the boot flag. says if we could boot this player if we wanted to.
-- this is not absolute, there are other conditions that could hide the "boot"
-- option. all this tells us is that someone else isn't currently nominated
-- for a boot
Popup_LobbyOpts.bIsMuted,
Popup_LobbyOpts.bIsFriend,
Popup_LobbyOpts.bCanBoot,
Popup_LobbyOpts.bIsGuest,
Popup_LobbyOpts.bCanAddFriend =
ScriptCB_GetLobbyPlayerFlags(Selection.namestr, Selection.indexstr)
Popup_LobbyOpts.bOnlyForPlayer = 1
Popup_LobbyOpts.fnDone = ifs_mp_lobby_fnLobbyOptionsPopupDone;
Popup_LobbyOpts.playerIndex = Selection.indexstr
Popup_LobbyOpts:fnActivate(1)
end -- selectedidx is valid
end -- (SM 7-Feb-05 NOT) not PC
end,
Input_Back = function(this)
if(this.bShellActive) then
ifelm_shellscreen_fnPlaySound(this.exitSound)
-- Shell is active. Must prompt before backing out of screen
ifs_mp_lobby_fnShowHideItems(this,nil)
Popup_YesNo.CurButton = "no" -- default
Popup_YesNo.fnDone = ifs_mp_lobby_fnLeavePopupDone
Popup_YesNo:fnActivate(1)
if(this.bAmHost) then
gPopup_fnSetTitleStr(Popup_YesNo,"ifs.onlinelobby.cancelsession")
else
gPopup_fnSetTitleStr(Popup_YesNo,"ifs.onlinelobby.leavesession")
end
ifs_mp_lobby_fnShowHideItems(this, nil)
else
-- Game is active. Just back up to pausemenu
ScriptCB_PopScreen()
end
end,
Input_Misc = function(this)
if(gPlatformStr ~= "PC") then
-- make sure this is updated
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
if(this.ForceBootVisible) then
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "forceboot")
else
ifs_mp_lobby_DoPopupVootBoot( 1 )
end
elseif(this.BootVisible) then
if( nil ) then
local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
if(not Selection) then
return
end
ScriptCB_LobbyAction(Selection.indexstr, Selection.namestr, "boot")
else
ifs_mp_lobby_DoPopupVootBoot( nil )
end
end
end
end,
Input_Start = function(this)
-- if(lobby_listbox_layout.SelectedIdx ) then
-- local Selection = ifs_mp_lobby_listbox_contents[lobby_listbox_layout.SelectedIdx]
-- ScriptCB_VoteKick(Selection.namestr )
-- ifelm_shellscreen_fnPlaySound(this.acceptSound)
-- end
end,
Input_GeneralUp = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnNavUp(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_GeneralDown = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnNavDown(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_LTrigger = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnPageUp(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
Input_RTrigger = function(this)
if(lobby_listbox_layout.SelectedIdx) then
ListManager_fnPageDown(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
end,
-- update bandwidth
Input_GeneralLeft = function(this)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
local new_value = ScriptCB_GetBandwidth() - 10
if ( new_value < 10 ) then
new_value = 10
end
ifs_mp_lobby_UpdateBandwidth( this, new_value )
ScriptCB_SetBandwidth( new_value )
end
-- ScriptCB_PreviousHost()
end,
Input_GeneralRight = function(this)
if ( ifs_mp_lobby_IsBandwidthVisible(this) ) then
local new_value = ScriptCB_GetBandwidth() + 10
if ( new_value > 100 ) then
new_value = 100
end
ifs_mp_lobby_UpdateBandwidth( this, new_value )
ScriptCB_SetBandwidth( new_value )
end
-- ScriptCB_NextHost()
end,
fDoubleClickTimer = 0.0,
Update = function(this, fDt)
-- Call default base class's update function (make button bounce)
gIFShellScreenTemplate_fnUpdate(this,fDt)
ScriptCB_UpdateLobby(nil)
this.fDoubleClickTimer = math.max(0, this.fDoubleClickTimer - fDt)
-- set the visibility of the boot button
ifs_mp_lobby_CalcCanBoot()
ifs_mp_lobby_CalcCanForceBoot()
if(this.bAutoLaunch) then
-- print("Autolaunching...")
ScriptCB_LaunchLobby()
end
-- bail?
if(ScriptCB_SkipToPlayerList()) then
if(ScriptCB_CheckPlayerListDone()) then
ScriptCB_PopScreen()
return
end
end
this.flashTimeElapsed = this.flashTimeElapsed + fDt
if (this.flashTimeElapsed > this.flashNextTime) then
this.flashNextTime = this.flashNextTime + this.flashInterval
end
end,
-- Callback (from C++) to repaint the listbox with the current contents
-- in the global ifs_mp_lobby_listbox_contents
RepaintListbox = function(this)
-- Sanity check
if(not ifs_mp_lobby_listbox_contents) then
return
end
local NumEntries = table.getn(ifs_mp_lobby_listbox_contents)
if(NumEntries < 1) then
lobby_listbox_layout.SelectedIdx = nil
else
if((not lobby_listbox_layout.SelectedIdx) or (lobby_listbox_layout.SelectedIdx < 1)) then
lobby_listbox_layout.SelectedIdx = 1
elseif (lobby_listbox_layout.SelectedIdx > NumEntries) then
lobby_listbox_layout.SelectedIdx = NumEntries
end
end
--print( "lobby_listbox_layout.CursorIdx = ", lobby_listbox_layout.CursorIdx )
--print( "lobby_listbox_layout.SelectedIdx = ", lobby_listbox_layout.SelectedIdx )
if(gPlatformStr ~= "PC") then
lobby_listbox_layout.CursorIdx = lobby_listbox_layout.SelectedIdx
ListManager_fnFillContents(this.listbox,ifs_mp_lobby_listbox_contents,lobby_listbox_layout)
end
end,
}
-- Do programatic work to set up this screen
function ifs_mp_lobby_fnBuildScreen(this)
local w,h = ScriptCB_GetSafeScreenInfo() -- of the usable screen
lobby_listbox_layout.width = w - 50 -- enough for sliders, etc
local HeightPer = lobby_listbox_layout.yHeight + lobby_listbox_layout.ySpacing
lobby_listbox_layout.showcount = math.floor((h - 180) / HeightPer)
-- enable idiot mode if XLive is enabled
ifs_mp_lobby.bIdiotMode = gPlatformStr == "XBox"
--this.stopitall.now = 1
this.listbox = NewButtonWindow {
ZPos = 200,
x = 0,
y = -20,
ScreenRelativeX = 0.5, -- center
ScreenRelativeY = 0.5, -- middle of screen
width = lobby_listbox_layout.width + 50,
height = lobby_listbox_layout.showcount * HeightPer + 30,
}
ListManager_fnInitList(this.listbox,lobby_listbox_layout)
-- Make column headers, fill them in
this.columnheaders = ifs_mp_lobby_Listbox_CreateItem {
bTitles = 1, --
width = lobby_listbox_layout.width,
height = lobby_listbox_layout.yHeight,
x = -10, -- account for scrollbar
y = 0,
}
this.columnheaders.ScreenRelativeX = 0.5
this.columnheaders.ScreenRelativeY = 0.5
if (gPlatformStr == "XBox" or
gPlatformStr == "PS2") then
this.columnheaders.y = this.listbox.y - (this.listbox.height * 0.45) - 30
else
this.columnheaders.y = this.listbox.y - (this.listbox.height * 0.49) - 30
end
-- set column header text
if (this.columnheaders.namefield) then
IFText_fnSetString(this.columnheaders.namefield, "ifs.MPLobby.name_header")
end
if (this.columnheaders.teamfield) then
IFText_fnSetString(this.columnheaders.teamfield, "ifs.MPLobby.team_header")
end
if (this.columnheaders.killsfield) then
IFText_fnSetString(this.columnheaders.killsfield, "ifs.Stats.kills")
end
if (this.columnheaders.pingfield) then
IFText_fnSetString(this.columnheaders.pingfield, "ifs.MPLobby.ping_header")
end
if (this.columnheaders.qosfield) then
IFText_fnSetString(this.columnheaders.qosfield, "ifs.MPLobby.qos_header")
end
if (this.columnheaders.voiceSendField and
this.columnheaders.voiceReceiveField) then
IFText_fnSetString(this.columnheaders.voiceSendField, "ifs.MPLobby.voice.sendheader")
IFText_fnSetString(this.columnheaders.voiceReceiveField, "ifs.MPLobby.voice.receiveheader")
end
if(gPlatformStr ~= "PC") then
this.Helptext_Misc = NewHelptext {
ScreenRelativeX = 0.0, -- left
ScreenRelativeY = 1.0, -- bottom
y = -40, -- second row of items
buttonicon = "btnmisc",
string = "ifs.onlinelobby.vote",
}
else
this.Helptext_Misc = NewPCIFButton {
ScreenRelativeX = 0.5, -- left
ScreenRelativeY = 1.0, -- bottom
y = -15, -- second row of items
btnw = 200,
btnh = ScriptCB_GetFontHeight("meu_myriadpro_small"),
font = "meu_myriadpro_small",
tag = "voteboot",
string = "ifs.onlinelobby.vote",
--nocreatebackground = 1,
}
this.Helptext_ForceBoot = NewPCIFButton {
ScreenRelativeX = 1.0, -- left
ScreenRelativeY = 1.0, -- bottom
y = -15, -- second row of items
x = -100,
btnw = 200,
btnh = ScriptCB_GetFontHeight("meu_myriadpro_small"),
font = "meu_myriadpro_small",
tag = "forceboot",
string = "ifs.onlinelobby.forceboot",
--nocreatebackground = 1,
}
end
-- ScriptCB_GetLobbyPlayerlist()
end
ifs_mp_lobby_fnBuildScreen(ifs_mp_lobby)
ifs_mp_lobby_fnBuildScreen = nil -- dump out of memory once built to save
ifs_mp_lobby_vbutton_layout = nil -- dump out of memory once built to save
AddIFScreen(ifs_mp_lobby,"ifs_mp_lobby")
ifs_mp_lobby = DoPostDelete(ifs_mp_lobby)
|
-- Copyright (c) 2015 Adobe Systems Incorporated. All rights reserved.
--
-- 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.
-- An initialization script on a per worker basis.
-- User: ddascal
-- Date: 07/12/14
-- Time: 16:44
--
local _M = {}
--- Loads a lua gracefully. If the module doesn't exist the exception is caught, logged and the execution continues
-- @param module path to the module to be loaded
--
local function loadrequire(module)
ngx.log(ngx.DEBUG, "Loading module [" .. tostring(module) .. "]")
local function requiref(module)
require(module)
end
local res = pcall(requiref, module)
if not (res) then
ngx.log(ngx.WARN, "Could not load module [", module, "].")
return nil
end
return require(module)
end
--- Initializes the `zmqLogger` used by `trackingRulesLogger.lua` from api-gateway-request-tracking module
-- @param parentObject
--
local function initZMQLogger(parentObject)
ngx.log(ngx.DEBUG, "Initializing ZMQLogger on property [zmqLogger]")
-- when the ZmqModule is not present the script does not break
local ZmqLogger = loadrequire("api-gateway.zmq.ZeroMQLogger")
if (ZmqLogger == nil) then
return
end
local zmq_publish_address = "ipc:///tmp/nginx_queue_listen"
ngx.log(ngx.INFO, "Starting new ZmqLogger on pid [", tostring(ngx.worker.pid()), "] on address [", zmq_publish_address, "]")
local zmqLogger = ZmqLogger:new()
zmqLogger:connect(ZmqLogger.SOCKET_TYPE.ZMQ_PUB, zmq_publish_address)
parentObject.zmqLogger = zmqLogger
end
local function initValidationFactory(parentObject)
parentObject.validation = require "api-gateway.validation.factory"
end
local function initTrackingFactory(parentObject)
parentObject.tracking = require "api-gateway.tracking.factory"
end
local function initMetricsFactory(parentObject)
parentObject.metrics = require "metrics.factory"
end
initValidationFactory(_M)
initZMQLogger(_M)
initTrackingFactory(_M)
initMetricsFactory(_M)
-- TODO: test health-check with the new version of Openresty
-- initRedisHealthCheck()
ngx.apiGateway = _M
|
--我的二维码页面
local MyQRCodeLayer = class("MyQRCodeLayer", cc.Layer)
local ExternalFun = appdf.req(appdf.EXTERNAL_SRC .. "ExternalFun")
local AnimationHelper = appdf.req(appdf.EXTERNAL_SRC .. "AnimationHelper")
local MultiPlatform = appdf.req(appdf.EXTERNAL_SRC .. "MultiPlatform")
function MyQRCodeLayer:ctor(info)
local csbNode = ExternalFun.loadCSB("Spreader/MyQRCodeLayer.csb"):addTo(self)
self._panelMask = csbNode:getChildByName("panel_mask")
self._content = csbNode:getChildByName("content")
--遮罩
self._panelMask:addTouchEventListener(function(ref, type)
if type == ccui.TouchEventType.ended then
dismissPopupLayer(self)
end
end)
--分享
local btnShare = self._content:getChildByName("btn_share")
btnShare:addClickEventListener(function()
--播放音效
ExternalFun.playClickEffect()
ExternalFun.popupTouchFilter(0, false)
captureScreenWithArea(self._qrCodeFrame, "qr_code.png", function(ok, savepath)
ExternalFun.dismissTouchFilter()
if ok then
MultiPlatform:getInstance():customShare(function(isok)
end, "我的推广码", "分享我的推广码", self._qrContent, savepath, "true")
end
end)
end)
--保存
local btnSave = self._content:getChildByName("btn_save")
btnSave:addClickEventListener(function()
--播放音效
ExternalFun.playClickEffect()
ExternalFun.popupTouchFilter(0, false)
captureScreenWithArea(self._qrCodeFrame, "qr_code.png", function(ok, savepath)
ExternalFun.dismissTouchFilter()
if ok then
if true == MultiPlatform:getInstance():saveImgToSystemGallery(savepath, "qr_code.png") then
showToast(nil, "您的推广码二维码图片已保存至系统相册", 2)
end
end
end)
end)
local contentSize = self._content:getContentSize()
--二维码
self._qrContent = GlobalUserItem.szSpreaderURL or yl.HTTP_URL
self._qrCode = QrNode:createQrNode(self._qrContent, 500, 5, 1)
self._qrCode:setPosition(contentSize.width / 2, contentSize.height / 2 + 40)
self._qrCode:addTo(self._content)
--logo
local logo = cc.Sprite:create("Spreader/logo.png")
logo:setPosition(self._qrCode:getPosition())
logo:addTo(self._content)
--保存二维码区域
local frameSize = cc.Director:getInstance():getOpenGLView():getFrameSize()
local areaSize = self._qrCode:getContentSize()
local scaleX = frameSize.width / appdf.WIDTH
local scaleY = frameSize.height / appdf.HEIGHT
local worldPt = self._qrCode:convertToWorldSpace(self._qrCode:getAnchorPointInPoints());
self._qrCodeFrame = cc.rect((worldPt.x - areaSize.width / 2) * scaleX, (worldPt.y - areaSize.height / 2) * scaleY, areaSize.width * scaleX, areaSize.height * scaleY)
-- 内容跳入
AnimationHelper.jumpIn(self._content)
end
--------------------------------------------------------------------------------------------------------------------
-- 事件处理
return MyQRCodeLayer |
require 'nn'
-- dummy values
local ninputs = 100
local nhiddens = 300
local noutputs = 10
-- Simple 2-layer neural network, with tanh hidden units
model = nn.Sequential()
model:add(nn.Reshape(ninputs)) -- can these be added behind the scenes?
model:add(nn.Linear(ninputs,nhiddens))
model:add(nn.Tanh())
model:add(nn.Linear(nhiddens,noutputs))
|
-- call single argument integer constructor
p1 = player.new(2)
-- p2 is still here from being
-- set with lua["p2"] = player(0); below
local p2shoots = p2:shoot()
assert(not p2shoots)
-- had 0 ammo
-- set variable property setter
p1.hp = 545;
-- get variable through property getter
print(p1.hp);
local did_shoot_1 = p1:shoot()
print(did_shoot_1)
print(p1.bullets)
local did_shoot_2 = p1:shoot()
print(did_shoot_2)
print(p1.bullets)
local did_shoot_3 = p1:shoot()
print(did_shoot_3)
-- can read
print(p1.bullets)
-- would error: is a readonly variable, cannot write
-- p1.bullets = 20
p1:boost()
|
local local0 = 0.3
local local1 = 0.3 - local0
local local2 = 0.3 - local0
local local3 = 0.3 - local0
local local4 = 0.3 - local0
local local5 = 0.4 - local0
local local6 = 3.5 - local0
local local7 = 0.4 - local0
local local8 = 3.3 - local0
local local9 = 0 - local0
local local10 = 0 - local0
local local11 = 4.9 - local0
local local12 = 0 - local0
local local13 = 0.3 - local0
local local14 = 4.3 - local0
local local15 = 0.4 - local0
local local16 = 5.6 - local0
local local17 = 0.3 - local0
local local18 = 4.2 - local0
local local19 = 3.7 - local0
local local20 = 3.5 - local0
local local21 = 3 - local0
local local22 = 0.4 - local0
function OnIf_217000(arg0, arg1, arg2)
if arg2 == 0 then
EmissaryFromSnakeMarsh217000_ActAfter_RealTime(arg0, arg1)
end
return
end
function EmissaryFromSnakeMarsh217000Battle_Activate(arg0, arg1)
local local0 = {}
local local1 = {}
local local2 = {}
Common_Clear_Param(local0, local1, local2)
local local3 = arg0:GetDist(TARGET_ENE_0)
local local4 = arg0:GetEventRequest()
local local5 = arg0:GetRandam_Int(1, 100)
if arg0:IsInsideTarget(TARGET_ENE_0, AI_DIR_TYPE_B, 240) then
if local3 <= 2.4 and arg0:HasSpecialEffectId(TARGET_SELF, 5611) == true then
local0[3] = 30
local0[19] = 70
else
local0[19] = 100
end
elseif arg0:HasSpecialEffectId(TARGET_SELF, 5611) == true then
if 8 <= local3 then
local0[1] = 5
local0[2] = 15
local0[3] = 0
local0[4] = 0
local0[5] = 0
local0[6] = 15
local0[7] = 15
local0[8] = 20
local0[9] = 30
local0[10] = 0
local0[11] = 0
local0[12] = 0
local0[13] = 0
elseif 4 <= local3 then
local0[1] = 15
local0[2] = 15
local0[3] = 5
local0[4] = 5
local0[5] = 5
local0[6] = 5
local0[7] = 5
local0[8] = 15
local0[9] = 15
local0[10] = 0
local0[11] = 0
local0[13] = 20
else
local0[1] = 20
local0[2] = 15
local0[3] = 10
local0[4] = 5
local0[5] = 5
local0[6] = 0
local0[7] = 0
local0[8] = 20
local0[9] = 0
local0[10] = 0
local0[11] = 0
local0[13] = 25
end
else
local0[1] = 0
local0[2] = 0
local0[3] = 0
local0[4] = 0
local0[5] = 0
local0[6] = 0
local0[7] = 0
local0[8] = 0
local0[9] = 0
local0[10] = 0
local0[11] = 0
local0[13] = 0
local0[14] = 100
local0[15] = 0
local0[16] = 0
end
local1[1] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act01)
local1[2] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act02)
local1[3] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act03)
local1[4] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act04)
local1[5] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act05)
local1[6] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act06)
local1[7] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act07)
local1[8] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act08)
local1[9] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act09)
local1[10] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act10)
local1[11] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act11)
local1[12] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act12)
local1[13] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act13)
local1[14] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act14)
local1[15] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act15)
local1[16] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act16)
local1[19] = REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_Act19)
Common_Battle_Activate(arg0, arg1, local0, local1, REGIST_FUNC(arg0, arg1, EmissaryFromSnakeMarsh217000_ActAfter_AdjustSpace), local2)
return
end
local0 = 3.3 - local0
function EmissaryFromSnakeMarsh217000_Act01(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3000, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 3.5 - local0
function EmissaryFromSnakeMarsh217000_Act02(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3001, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 1.7 - local0
function EmissaryFromSnakeMarsh217000_Act03(arg0, arg1, arg2)
local local0 = arg0:GetDist(TARGET_ENE_0)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = arg0:GetRandam_Int(1, 100)
local local3 = UPVAL0
local local4 = UPVAL0
local local5 = 0
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3002, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 0
return GetWellSpace_Odds
end
local0 = 4 - local0
function EmissaryFromSnakeMarsh217000_Act04(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3003, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = local6
local0 = local8
local0 = local11
function EmissaryFromSnakeMarsh217000_Act05(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0 + 1
local local2 = UPVAL1 + 1
local local3 = UPVAL0
local local4 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local4 = 999
else
local4 = UPVAL0
end
if local3 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local3, local4, 0, 3)
end
if local0 <= 25 then
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3004, TARGET_ENE_0, local1, 0, 0)
elseif local0 <= 55 then
arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 30, 3004, TARGET_ENE_0, local1, 0, 0)
arg1:AddSubGoal(GOAL_COMMON_ComboFinal, 30, 3005, TARGET_ENE_0, local2, 0)
else
arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 30, 3004, TARGET_ENE_0, local1, 0, 0)
arg1:AddSubGoal(GOAL_COMMON_ComboRepeat, 30, 3005, TARGET_ENE_0, local2, 0)
arg1:AddSubGoal(GOAL_COMMON_ComboFinal, 30, 3007, TARGET_ENE_0, UPVAL2 + 1, 0)
end
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 4.9 - local0
function EmissaryFromSnakeMarsh217000_Act06(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3006, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 7.8 - local0
function EmissaryFromSnakeMarsh217000_Act07(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3008, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = local14
function EmissaryFromSnakeMarsh217000_Act08(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 999
if arg0:GetRandam_Int(1, 100) <= 30 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3009, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = local16
local0 = local18
function EmissaryFromSnakeMarsh217000_Act09(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0 + 1
local local2 = UPVAL0
if local2 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local2, UPVAL0, 0, 3)
end
if arg0:GetRandam_Int(1, 100) <= 30 then
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3010, TARGET_ENE_0, local1, 0, 0)
else
arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 30, 3010, TARGET_ENE_0, local1, 0, 0)
arg1:AddSubGoal(GOAL_COMMON_ComboFinal, 30, 3011, TARGET_ENE_0, UPVAL1 + 1, 0)
end
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 13 - local0
function EmissaryFromSnakeMarsh217000_Act10(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = UPVAL0
local local2 = 999
if arg0:GetRandam_Int(1, 100) <= 70 then
local2 = 999
else
local2 = UPVAL0
end
if local1 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local1, local2, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3012, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 12.9 - local0
function EmissaryFromSnakeMarsh217000_Act11(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = UPVAL0
if local2 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local2, 999, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3013, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 4.7 - local0
function EmissaryFromSnakeMarsh217000_Act13(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = UPVAL0
if local2 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local2, UPVAL0, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3015, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = 13 - local0
function EmissaryFromSnakeMarsh217000_Act12(arg0, arg1, arg2)
local local0 = arg0:GetDist(TARGET_ENE_0)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = arg0:GetRandam_Int(1, 100)
local local3 = UPVAL0
local local4 = 999
local local5 = 0
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3014, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 0
return GetWellSpace_Odds
end
function EmissaryFromSnakeMarsh217000_Act14(arg0, arg1, arg2)
local local0 = arg0:GetDist(TARGET_ENE_0)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = arg0:GetRandam_Int(1, 100)
local local3 = 999
local local4 = 999
local local5 = 0
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3020, TARGET_ENE_0, 999, 0, 0)
GetWellSpace_Odds = 50
return GetWellSpace_Odds
end
local0 = local6
local0 = local8
local0 = local11
function EmissaryFromSnakeMarsh217000_Act15(arg0, arg1, arg2)
local local0 = UPVAL0 + 1
local local1 = UPVAL2 + 1
local local2 = UPVAL0
local local3 = 0
if arg0:GetRandam_Int(1, 100) <= 30 then
local3 = 999
else
local3 = UPVAL0
end
if local2 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local2, local3, 0, 3)
end
if arg0:GetRandam_Int(1, 100) <= 45 then
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3004, TARGET_ENE_0, local0, 0, 0)
else
arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 30, 3004, TARGET_ENE_0, local0, 0, 0)
arg1:AddSubGoal(GOAL_COMMON_ComboFinal, 30, 3005, TARGET_ENE_0, UPVAL1 + 1, 0)
end
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
local0 = local16
local0 = local18
function EmissaryFromSnakeMarsh217000_Act16(arg0, arg1, arg2)
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = UPVAL1 + 1
local local3 = UPVAL0
if local3 <= arg0:GetDist(TARGET_ENE_0) then
Approach_Act(arg0, arg1, local3, UPVAL0, 0, 3)
end
arg1:AddSubGoal(GOAL_COMMON_ComboAttackTunableSpin, 30, 3010, TARGET_ENE_0, UPVAL0 + 1, 0, 0)
GetWellSpace_Odds = 100
return GetWellSpace_Odds
end
function EmissaryFromSnakeMarsh217000_Act19(arg0, arg1, arg2)
local local0 = arg0:GetDist(TARGET_ENE_0)
local local1 = arg0:GetRandam_Int(1, 100)
if arg0:IsInsideTarget(TARGET_ENE_0, AI_DIR_TYPE_R, 180) then
if local1 <= 30 then
arg1:AddSubGoal(GOAL_COMMON_SidewayMove, 3, TARGET_ENE_0, 0, arg0:GetRandam_Int(30, 45), true, true, -1)
elseif local1 <= 70 then
arg1:AddSubGoal(GOAL_COMMON_SpinStep, 5, 702, TARGET_ENE_0, -1, AI_DIR_TYPE_B, 4)
else
arg1:AddSubGoal(GOAL_COMMON_Turn, 3, TARGET_ENE_0, 30, 0, 0)
end
elseif local1 <= 30 then
arg1:AddSubGoal(GOAL_COMMON_SidewayMove, 3, TARGET_ENE_0, 1, arg0:GetRandam_Int(30, 45), true, true, -1)
elseif local1 <= 70 then
arg1:AddSubGoal(GOAL_COMMON_SpinStep, 5, 703, TARGET_ENE_0, -1, AI_DIR_TYPE_B, 4)
else
arg1:AddSubGoal(GOAL_COMMON_Turn, 3, TARGET_ENE_0, 30, 0, 0)
end
GetWellSpace_Odds = 0
return GetWellSpace_Odds
end
function EmissaryFromSnakeMarsh217000_ActAfter_AdjustSpace(arg0, arg1, arg2)
arg1:AddSubGoal(GOAL_COMMON_If, 10, 0)
return
end
function EmissaryFromSnakeMarsh217000_ActAfter_RealTime(arg0, arg1)
local local0 = arg0:GetRandam_Int(1, 100)
if arg0:HasSpecialEffectId(TARGET_SELF, 5611) == true then
if arg0:GetDist(TARGET_ENE_0) <= 2.2 and local0 <= 40 then
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3002, TARGET_ENE_0, AttDist, 0, 0)
else
arg1:AddSubGoal(GOAL_COMMON_ApproachTarget, 10, TARGET_ENE_0, 4, TARGET_ENE_0, false, -1)
end
elseif local0 <= 30 then
arg1:AddSubGoal(GOAL_COMMON_LeaveTarget, arg0:GetRandam_Float(1.5, 2.5), TARGET_ENE_0, 5, TARGET_ENE_0, true, -1)
else
arg1:AddSubGoal(GOAL_COMMON_SidewayMove, arg0:GetRandam_Float(2.5, 3.5), TARGET_ENE_0, bRight, arg0:GetRandam_Int(45, 60), true, true, -1)
end
return
end
function EmissaryFromSnakeMarsh217000Battle_Update(arg0, arg1)
return GOAL_RESULT_Continue
end
function EmissaryFromSnakeMarsh217000Battle_Terminate(arg0, arg1)
return
end
local0 = local14
function EmissaryFromSnakeMarsh217000Battle_Interupt(arg0, arg1)
if arg0:IsLadderAct(TARGET_SELF) then
return false
end
local local0 = arg0:GetRandam_Int(1, 100)
local local1 = arg0:GetRandam_Int(1, 100)
local local2 = arg0:GetRandam_Int(1, 100)
if arg0:IsInterupt(INTERUPT_UseItem) and local0 <= 70 then
arg1:ClearSubGoal()
Approach_Act(arg0, arg1, UPVAL0, 0, 0)
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3009, TARGET_ENE_0, UPVAL0 + 1, 0, -1)
return true
elseif arg0:IsInterupt(INTERUPT_Damaged) then
if arg0:HasSpecialEffectId(TARGET_SELF, 5656) == true and local0 <= 10 then
arg1:ClearSubGoal()
arg1:AddSubGoal(GOAL_COMMON_SpinStep, 5, 701, TARGET_ENE_0, 0, AI_DIR_TYPE_B, 4)
elseif arg0:HasSpecialEffectId(TARGET_SELF, 5611) == true and local0 <= 25 then
if arg0:GetDist(TARGET_ENE_0) <= 2.5 then
arg1:ClearSubGoal()
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3002, TARGET_ENE_0, AttDist, 0, 0)
else
arg1:ClearSubGoal()
arg1:AddSubGoal(GOAL_COMMON_SpinStep, 5, 701, TARGET_ENE_0, 0, AI_DIR_TYPE_B, 4)
end
elseif arg0:HasSpecialEffectId(TARGET_SELF, 5656) == false and arg0:HasSpecialEffectId(TARGET_SELF, 5611) == false and local0 <= 30 then
arg1:ClearSubGoal()
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3020, TARGET_ENE_0, 999, 0, 0)
end
return true
elseif FindAttack_Step(arg0, arg1, 3, 20, 100, 0, 0, 3.5) then
return true
end
local local3 = arg0:GetRandam_Int(1, 100)
local local4 = arg0:GetRandam_Int(1, 100)
local local5 = arg0:GetDist(TARGET_ENE_0)
local local6 = Shoot_2dist(arg0, arg1, 7, 20, 20, 40)
if local6 == 1 then
arg1:AddSubGoal(GOAL_COMMON_AttackTunableSpin, 10, 3004, TARGET_ENE_0, AttDist, 0, -1)
elseif local6 == 2 then
if arg0:IsOnNearMesh(TARGET_SELF, AI_DIR_TYPE_R, 1, 5) == true then
arg1:AddSubGoal(GOAL_COMMON_SidewayMove, 1.5, TARGET_ENE_0, 1, arg0:GetRandam_Int(30, 45), true, true, -1)
elseif arg0:IsOnNearMesh(TARGET_SELF, AI_DIR_TYPE_L, 1, 5) == true then
arg1:AddSubGoal(GOAL_COMMON_SidewayMove, 1.5, TARGET_ENE_0, 0, arg0:GetRandam_Int(30, 45), true, true, -1)
end
return true
end
return false
end
return
|
local Panel = LGUI.class(LGUI.Element, function(self, parent)
self.super.init(self, parent)
self.width = 100
self.height = 100
self.color = nil
self:applySkin(LGUI.skin.Panel)
end)
function Panel:applySkin(skin)
self.color = skin.color
end
function Panel:setColor(color)
self.color = color
end
function Panel:getColor()
return self.color
end
function Panel:paint()
local posX, posY = self:getAbsolutePosition()
LGUI.renderer.setColor(self.color)
LGUI.renderer.rectangle(LGUI.Enums.RectangleFillMode.Fill, posX, posY, self.width, self.height, 0, 0)
end
LGUI.Panel = Panel
|
-- Zytharian (roblox: Legend26)
-- Services
local projectRoot = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")
-- Includes
local Classes = require(projectRoot.Modules.ClassSystem)
local Util = require(projectRoot.Modules.Utilities)
local LEnums = require(projectRoot.Modules.Enums)
--[[
init(Rbx::Model model)
Properties:
readonly string name
Methods:
void setMode(Enum DeviceMode)
Enum::DeviceMode getMode()
Rbx::CFrame getAdjustedRefCFrame()
void doTeleport(Transporter destination)
void linkTransporter(Transporter other)
bool isActive()
Events:
]]
--------
-- Header end
--------
if not RS:FindFirstChild"CR_TeleportRequest" then
Instance.new("RemoteEvent", RS).Name = "CR_TeleportRequest"
end
Classes.class 'Transporter' (function (this)
--[[
Internal properties:
string name
Rbx::Model model
Door mainDoor
Door shutter
bool isRunning
Enum::DeviceMode mode
table linkedTransporters
EventPropagator buttonProp
table destinationButtons
-- {TextButton = Transporter destination}
number numLinkedTo
Elevator elevator
Rbx::TextButton optionButton
]]
function this:init (model)
self.model = model
self.name = model.Name
self.isRunning = false
self.mode = LEnums.DeviceMode:GetItem"Normal"
self.linkedTransporters = {}
self.numLinkedTo = 0
RS.TransporterSurfaceGui:Clone().Parent = model.Unit.Display
model.PrimaryPart = model.Unit.Ref
-- Create outer door
self.mainDoor = Classes.new 'Door' (model.Unit.Inner)
-- Create shutter
self.shutter = Classes.new 'Door' (model.Unit.Shutter)
self.shutter:setMode(LEnums.DeviceMode:GetItem"InterfaceDisabled")
self.shutter:changeStateAsync(true)
-- Set up shutter's gui
self.buttonProp = Classes.new 'EventPropagator' ("TextButton", "MouseButton1Click")
self.optionButton = model.Unit.Display.TransporterSurfaceGui.Options.Transport
self.buttonProp:addObject(self.optionButton)
self.destinationButtons = {}
self.buttonProp.eventFired:Connect(function (player, button)
self:onButtonClicked(player, button)
end)
self.elevator = Classes.new 'Elevator' (model)
if not self.elevator.isElevator then
return
end
self.elevator.floorChangeComplete:Connect(function ()
self:doModeAttrib(self.mode)
end)
self.elevator.allowFloorChange = (function ()
if self.isRunning or self.mode ~= LEnums.DeviceMode:GetItem"Normal" then
return
end
-- Close shutter and inner door
self.mainDoor:setMode(LEnums.DeviceMode:GetItem"LocalLock")
self.shutter:changeStateAsync(false)
repeat wait() until not self.mainDoor.isOpen and not self.shutter.isOpen
and not self.mainDoor.isRunning and not self.shutter.isRunning
return self:getPlayersInside()
end)
end
function this.member:onButtonClicked(player, button)
if button == self.optionButton then
self.model.Unit.Display.TransporterSurfaceGui.Main.Elevator.Visible = false
self.model.Unit.Display.TransporterSurfaceGui.Main.Transporter.Visible = true
return
end
local destination = self.destinationButtons[button]
if not destination or self.mode ~= LEnums.DeviceMode:GetItem"Normal"
or destination:getMode() ~= LEnums.DeviceMode:GetItem"Normal"
or self:isActive() or destination:isActive() then
return
end
-- Do both async
coroutine.wrap(function ()
self:doTeleport(destination)
end)()
destination:doTeleport(self)
end
function this.member:doTeleport(destination)
if self:isActive() then
return
end
self.isRunning = true
-- Close and lock doors
self.mainDoor:setMode(LEnums.DeviceMode:GetItem"LocalLock")
self.shutter:changeStateAsync(false)
repeat wait() until not self.mainDoor.isOpen and not self.shutter.isOpen
and not self.mainDoor.isRunning and not self.shutter.isRunning
-- Transport players
for _,v in next, self:getPlayersInside() do
local mainPart = Util.playerCharacterMainPart(v.Character)
local newCF = destination:getAdjustedRefCFrame():toWorldSpace(
self:getAdjustedRefCFrame():toObjectSpace(mainPart.CFrame))
if RS:FindFirstChild"CR_TeleportRequest" then
RS.CR_TeleportRequest:FireClient(v, {newCF})
else
error("No RS.CR_TeleportRequest remote event")
end
end
wait(4)
self.isRunning = false
self:doModeAttrib(self.mode)
end
function this.member:getMode()
return self.mode
end
function this.member:setMode(mode)
if self.mode == mode then
return
end
self:doModeAttrib(mode)
self.elevator:setMode(mode)
self.mode = mode
end
function this.member:doModeAttrib(mode)
local deviceMode = LEnums.DeviceMode
if mode == deviceMode:GetItem"Unpowered" then
if not self.isRunning and not self.elevator.isRunning then
self.mainDoor:setMode(deviceMode:GetItem"Unpowered")
end
for _,v in next, self.model.Unit.Display.TransporterSurfaceGui:GetChildren() do
v.Visible = false
end
self:setLightingEnabled(false)
elseif mode == deviceMode:GetItem"Normal" then
if not self.isRunning and not self.elevator.isRunning then
self.mainDoor:setMode(deviceMode:GetItem"Normal")
self.shutter:changeStateAsync(true)
end
for _,v in next, self.model.Unit.Display.TransporterSurfaceGui:GetChildren() do
v.Visible = true
end
self:setLightingEnabled(true)
elseif mode == deviceMode:GetItem"LocalLock" then
if not self.isRunning and not self.elevator.isRunning then
self.mainDoor:setMode(deviceMode:GetItem"LocalLock")
self.shutter:changeStateAsync(false)
end
self.model.Unit.Display.TransporterSurfaceGui.Background.Visible = true
self:setLightingEnabled(true)
elseif mode == deviceMode:GetItem"GeneralLock" then
if not self.isRunning and not self.elevator.isRunning then
self.mainDoor:setMode(deviceMode:GetItem"GeneralLock")
self.shutter:changeStateAsync(false)
end
self.model.Unit.Display.TransporterSurfaceGui.Background.Visible = true
self:setLightingEnabled(true)
else
error("Unknown door mode: " .. tostring(mode))
end
end
function this.member:setLightingEnabled(enabled)
if self.model.Unit:FindFirstChild"Light" then
self.model.Unit.Light.RealLight.SurfaceLight.Enabled = enabled
self.model.Unit.Light.Neon.Material = enabled and Enum.Material.Neon or Enum.Material.Plastic
end
end
function this.member:getAdjustedRefCFrame()
return self.model.PrimaryPart.CFrame + Vector3.new(0,4,0)
end
function this.member:linkTransporter(other)
if self.linkedTransporters[other] then
error("Attempted double link to " .. other.name)
end
self.linkedTransporters[other] = true
self.numLinkedTo = self.numLinkedTo + 1
-- Add button on gui
local button = self.model.Unit.Display.TransporterSurfaceGui.Main.Template:Clone()
button.Parent = self.model.Unit.Display.TransporterSurfaceGui.Main.Transporter
button.Position = UDim2.new(0, 0, 0, 75*(self.numLinkedTo - 1))
button.Visible = true
button.Text = "||| " .. other.name
self.destinationButtons[button] = other
self.buttonProp:addObject(button)
end
function this.member:getPlayersInside()
-- Create region
local R3 = Util.getRegion3Around(self:getAdjustedRefCFrame(), Vector3.new(6, 4, 12))
-- Get players
return Util.getPlayersInRegion3(R3, self.model)
end
function this.member:isActive()
return self.isRunning or self.elevator.isRunning
end
-- public properties
this.get.name = true
-- public methods
this.get.getMode = true
this.get.setMode = true
this.get.doTeleport = true
this.get.linkTransporter = true
this.get.getAdjustedRefCFrame = true
this.get.isActive = true
end)
return false |
local tokenizer = require("latoft.compiler.tokenizer")
local parser = require("latoft.compiler.parser")
local assembler = require("latoft.compiler.assembler")
local compiler = {}
compiler.parse = function(source, source_path)
local text = tokenizer.read(source, source_path)
return parser.read(text)
end
compiler.parse_file = function(source, source_path)
local text = tokenizer.read_file(source, source_path)
return parser.read(text)
end
compiler.compile = function(source, source_path)
local text = tokenizer.read(source, source_path)
local phrases = parser.read(text)
return assembler.build(phrases)
end
compiler.compile_file = function(file_path)
local text = tokenizer.read_file(file_path)
local phrases = parser.read(text)
return assembler.build(phrases)
end
compiler.compile_phrases = function(phrases)
return assembler.build(phrases)
end
return compiler |
--
-- Registry is a way to resolve cyclic dependencies which normally can exist
-- between files of the same module/library.
--
-- Files, which want to expose their API to the other files, which in turn can't
-- require the formers directly, should put their API to the registry.
--
-- The files should use the registry to get API of the other files. They don't
-- require() and use the latter directly if there is a known loop dependency
-- between them.
--
-- At runtime, when all require() are done, the registry is full, and all the
-- files see API of each other.
--
-- Having the modules accessed via the registry adds at lest +1 indexing
-- operation at runtime when need to get a function from there. But sometimes it
-- can be cached to reduce the effect in perf-sensitive code. For example, like
-- this:
--
-- local lreg = require('vshard.registry')
--
-- local storage_func
--
-- local function storage_func_no_cache(...)
-- storage_func = lreg.storage.func
-- return storage_func(...)
-- end
--
-- storage_func = storage_func_no_cache
--
-- The code will always call storage_func(), but will load it from the registry
-- only on first invocation.
--
-- However in case reload is important, it is not possible - the original
-- function object in the registry may change. In such situation still makes
-- sense to cache at least 'lreg.storage' to save 1 indexing operation.
--
-- local lreg = require('vshard.registry')
--
-- local lstorage
-- local storage_func
--
-- local function storage_func_cache(...)
-- return lstorage.storage_func(...)
-- end
--
-- local function storage_func_no_cache(...)
-- lstorage = lref.storage
-- storage_func = storage_func_cache
-- return lstorage.storage_func(...)
-- end
--
-- storage_func = storage_func_no_cache
--
-- A harder way would be to use the first approach + add triggers on reload of
-- the cached module to update the cached function refs. If the code is
-- extremely perf-critical (which should not be Lua then).
--
local MODULE_INTERNALS = '__module_vshard_registry'
local M = rawget(_G, MODULE_INTERNALS)
if not M then
M = {}
rawset(_G, MODULE_INTERNALS, M)
end
return M
|
local lib = LibStub and LibStub("LibClassicDurations", true)
if not lib then return end
local Type, Version = "SpellTable", 51
if lib:GetDataVersion(Type) >= Version then return end -- older versions didn't have that function
local Spell = lib.AddAura
local Talent = lib.Talent
local INFINITY = math.huge
local _, class = UnitClass("player")
local locale = GetLocale()
-- Temporary
-- Erases Fire Vulnerability from the name to id table in case older version of the lib written it there
if locale == "zhCN" then
lib.spellNameToID[GetSpellInfo(980)] = nil
end
-- https://github.com/rgd87/LibClassicDurations/issues/11
lib.indirectRefreshSpells = {
[GetSpellInfo(11597)] = { -- Sunder Armor
events = {
["SPELL_CAST_SUCCESS"] = true
},
targetSpellID = 11597,
},
[GetSpellInfo(25357)] = { -- Healing Wave
events = {
["SPELL_CAST_SUCCESS"] = true
},
targetSpellID = 29203, -- Healing Way
},
}
if class == "MAGE" then
lib.indirectRefreshSpells[GetSpellInfo(10207)] = { -- Scorch
events = {
["SPELL_DAMAGE"] = true
},
targetSpellID = 22959, -- Fire Vulnerability
targetResistCheck = true,
condition = function(isMine) return isMine end,
-- it'll refresg only from mages personal casts which is fine
-- because if mage doesn't have imp scorch then he won't even see a Fire Vulnerability timer
}
lib.indirectRefreshSpells[GetSpellInfo(25304)] = { -- Frostbolt
events = {
["SPELL_DAMAGE"] = true
},
targetSpellID = 12579, -- Winter's Chill
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
lib.indirectRefreshSpells[GetSpellInfo(10161)] = { -- Cone of Cold
events = {
["SPELL_DAMAGE"] = true
},
targetSpellID = 12579, -- Winter's Chill
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
lib.indirectRefreshSpells[GetSpellInfo(10230)] = { -- Frost Nova
events = {
["SPELL_DAMAGE"] = true
},
targetSpellID = 12579, -- Winter's Chill
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
lib.indirectRefreshSpells[GetSpellInfo(10)] = { -- Blizzard
events = {
["SPELL_PERIODIC_DAMAGE"] = true
},
applyAura = true,
targetSpellID = 12486, -- Imp Blizzard
}
end
if class == "PRIEST" then
-- Shadow Weaving
lib.indirectRefreshSpells[GetSpellInfo(10894)] = { -- SW:Pain
events = {
["SPELL_AURA_APPLIED"] = true,
["SPELL_AURA_REFRESH"] = true,
},
targetSpellID = 15258, -- Shadow Weaving
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
lib.indirectRefreshSpells[GetSpellInfo(10947)] = { -- Mind Blast
events = {
["SPELL_DAMAGE"] = true,
},
targetSpellID = 15258, -- Shadow Weaving
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
lib.indirectRefreshSpells[GetSpellInfo(18807)] = { -- Mind Flay
events = {
["SPELL_AURA_APPLIED"] = true,
["SPELL_AURA_REFRESH"] = true,
},
targetSpellID = 15258, -- Shadow Weaving
targetResistCheck = true,
condition = function(isMine) return isMine end,
}
end
------------------
-- GLOBAL
------------------
Spell( 2479, { duration = 30 }) -- Honorless Target
Spell(1604, { duration = 4 }) -- Common Daze
Spell( 23605, { duration = 5 }) -- Nightfall (Axe) Proc
Spell( 835, { duration = 3 }) -- Tidal Charm
Spell( 11196, { duration = 60 }) -- Recently Bandaged
Spell( 16928, { duration = 45 }) -- Armor Shatter, procced by Annihilator, axe weapon
Spell({ 13099, 13138, 16566 }, {
duration = function(spellID)
if spellID == 13138 then return 20 -- backfire
elseif spellID == 16566 then return 30 -- backfire
else return 10 end
end
}) -- Net-o-Matic
Spell( 23451, { duration = 10 }) -- Battleground speed buff
Spell( 23493, { duration = 10 }) -- Battleground heal buff
Spell( 23505, { duration = 60 }) -- Battleground damage buff
Spell({ 4068 }, { duration = 3 }) -- Iron Grenade
Spell({ 19769 }, { duration = 3 }) -- Thorium Grenade
Spell( 6615, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Free Action Potion
Spell( 24364, { duration = 5, type = "BUFF", buffType = "Magic" }) -- Living Action Potion
Spell( 3169, { duration = 6, type = "BUFF", buffType = "Magic" }) -- Limited Invulnerability Potion
Spell( 16621, { duration = 3, type = "BUFF" }) -- Invulnerable Mail
Spell( 1090, { duration = 30 }) -- Magic Dust
Spell( 13327, { duration = 30 }) -- Reckless Charge
Spell({ 26740, 13181 }, { duration = 20 }) -- Mind Control Cap + Backfire
Spell( 11359, { duration = 30, type = "BUFF" }) -- Restorative Potion
Spell( 6727, { duration = 30 }) -- Violet Tragan
Spell( 5024, { duration = 10, type = "BUFF" }) -- Skull of Impending Doom
Spell( 2379, { duration = 15, type = "BUFF", buffType = "Magic" }) -- Swiftness Potion
Spell( 5134, { duration = 10 }) -- Flash Bomb
Spell( 23097, { duration = 5, type = "BUFF" }) -- Fire Reflector
Spell( 23131, { duration = 5, type = "BUFF" }) -- Frost Reflector
Spell( 23132, { duration = 5, type = "BUFF" }) -- Shadow Reflector
Spell({ 25750, 25747, 25746, 23991 }, { duration = 15, type = "BUFF" }) -- AB Trinkets
Spell( 23506, { duration = 20, type = "BUFF" }) -- Arena Grand Master trinket
Spell( 29506, { duration = 20, type = "BUFF" }) -- Burrower's Shell trinket
Spell( 12733, { duration = 30, type = "BUFF" }) -- Blacksmith trinket
-- Spell( 15753, { duration = 2 }) -- Linken's Boomerang stun
-- Spell( 15752, { duration = 10 }) -- Linken's Boomerang disarm
Spell( 14530, { duration = 10, type = "BUFF" }) -- Nifty Stopwatch
Spell( 13237, { duration = 3 }) -- Goblin Mortar trinket
Spell( 21152, { duration = 3 }) -- Earthshaker, weapon proc
Spell( 14253, { duration = 8, type = "BUFF" }) -- Black Husk Shield
Spell( 9175, { duration = 15, type = "BUFF" }) -- Swift Boots
Spell( 13141, { duration = 20, type = "BUFF" }) -- Gnomish Rocket Boots
Spell( 8892, { duration = 20, type = "BUFF" }) -- Goblin Rocket Boots
Spell( 9774, { duration = 5, type = "BUFF" }) -- Spider Belt & Ornate Mithril Boots
Spell({ 746, 1159, 3267, 3268, 7926, 7927, 10838, 10839, 18608, 18610, 23567, 23568, 23569, 23696, 24412, 24413, 24414}, { duration = 8, type = "BUFF" }) -- First Aid
-------------
-- RACIALS
-------------
Spell( 26635 ,{ duration = 10, type = "BUFF" }) -- Berserking
Spell( 20600 ,{ duration = 20, type = "BUFF" }) -- Perception
Spell( 23234 ,{ duration = 15, type = "BUFF" }) -- Blood Fury
Spell( 23230 ,{ duration = 25 }) -- Blood Fury debuff
Spell( 20594 ,{ duration = 8, type = "BUFF" }) -- Stoneform
Spell( 20549 ,{ duration = 2 }) -- War Stomp
Spell( 7744, { duration = 5, type = "BUFF" }) -- Will of the Forsaken
-------------
-- PRIEST
-------------
Spell( 15473, { duration = INFINITY, type = "BUFF" }) -- Shadowform
Spell( 14751, { duration = INFINITY, type = "BUFF", buffType = "Magic" }) -- Inner focus
-- Why long auras are disabled
-- When you first get in combat log range with a player,
-- you'll get AURA_APPLIED event as if it was just applied, when it actually wasn't.
-- That's extremely common for these long self-buffs
-- Long raid buffs now have cast filter, that is only if you directly casted a spell it'll register
-- Cast Filter is ignored for enemies, so some personal buffs have it to still show enemy buffs
Spell({ 1243, 1244, 1245, 2791, 10937, 10938 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Power Word: Fortitude
Spell({ 21562, 21564 }, { duration = 3600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Prayer of Fortitude
Spell({ 976, 10957, 10958 }, { duration = 600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Shadow Protection
Spell( 27683, { duration = 600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Prayer of Shadow Protection
Spell({ 14752, 14818, 14819, 27841 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Divine Spirit
Spell( 27681, { duration = 3600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Prayer of Spirit
Spell({ 588, 602, 1006, 7128, 10951, 10952 }, { duration = 600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Inner Fire
Spell({ 14743, 27828 }, { duration = 6, type = "BUFF", buffType = "Magic" }) -- Focused Casting (Martyrdom)
Spell( 27827, { duration = 10, type = "BUFF" }) -- Spirit of Redemption
Spell( 15271, { duration = 15, type = "BUFF" }) -- Spirit Tap
Spell({ 2943, 19249, 19251, 19252, 19253, 19254 }, { duration = 120 }) -- Touch of Weakness Effect
Spell({ 13896, 19271, 19273, 19274, 19275 }, { duration = 15, type = "BUFF" }) -- Feedback
Spell({ 2651, 19289, 19291, 19292, 19293 }, { duration = 15, type = "BUFF" }) -- Elune's Grace
Spell({ 9035, 19281, 19282, 19283, 19284, 19285 }, { duration = 120 }) -- Hex of Weakness
Spell( 6346, { duration = 600, type = "BUFF", buffType = "Magic" }) -- Fear Ward
Spell({ 7001, 27873, 27874 }, { duration = 10, type = "BUFF", buffType = "Magic" }) -- Lightwell Renew
Spell( 552, { duration = 20, type = "BUFF", buffType = "Magic" }) -- Abolish Disease
Spell({ 17, 592, 600, 3747, 6065, 6066, 10898, 10899, 10900, 10901 }, {duration = 30, type = "BUFF", buffType = "Magic" }) -- PWS
Spell( 6788, { duration = 15 }) -- Weakened Soul
Spell({ 139, 6074, 6075, 6076, 6077, 6078, 10927, 10928, 10929, 25315 }, { duration = 15, type = "BUFF", buffType = "Magic" }) -- Renew
Spell( 15487, { duration = 5 }) -- Silence
Spell({ 10797, 19296, 19299, 19302, 19303, 19304, 19305 }, { duration = 6, stacking = true }) -- starshards
Spell({ 2944, 19276, 19277, 19278, 19279, 19280 }, { duration = 24, stacking = true }) --devouring plague
Spell({ 453, 8192, 10953 }, { duration = 15 }) -- mind soothe
Spell({ 9484, 9485, 10955 }, {
duration = function(spellID)
if spellID == 9484 then return 30
elseif spellID == 9485 then return 40
else return 50 end
end
}) -- Shackle Undead
Spell( 10060, { duration = 15, type = "BUFF", buffType = "Magic" }) --Power Infusion
Spell({ 14914, 15261, 15262, 15263, 15264, 15265, 15266, 15267 }, { duration = 10, stacking = true }) -- Holy Fire, stacking?
Spell({ 586, 9578, 9579, 9592, 10941, 10942 }, { duration = 10, type = "BUFF" }) -- Fade
Spell({ 8122, 8124, 10888, 10890 }, { duration = 8, }) -- Psychic Scream
Spell({ 589, 594, 970, 992, 2767, 10892, 10893, 10894 }, { stacking = true,
duration = function(spellID, isSrcPlayer)
-- Improved SWP, 2 ranks: Increases the duration of your Shadow Word: Pain spell by 3 sec.
local talents = isSrcPlayer and 3*Talent(15275, 15317) or 0
return 18 + talents
end
}) -- SW:P
Spell( 15269 ,{ duration = 3 }) -- Blackout
if class == "PRIEST" then
Spell( 15258 ,{
duration = function(spellID, isSrcPlayer)
-- Only SP himself can see the timer
if Talent(15257, 15331, 15332, 15333, 15334) > 0 then
return 15
else
return nil
end
end
}) -- Shadow Weaving
end
Spell( 15286 ,{ duration = 60 }) -- Vampiric Embrace
Spell({ 15407, 17311, 17312, 17313, 17314, 18807 }, { duration = 3 }) -- Mind Flay
Spell({ 605, 10911, 10912 }, { duration = 60 }) -- Mind Control
---------------
-- DRUID
---------------
Spell( 768, { duration = INFINITY, type = "BUFF" }) -- Cat Form
Spell( 783, { duration = INFINITY, type = "BUFF" }) -- Travel Form
Spell( 5487, { duration = INFINITY, type = "BUFF" }) -- Bear Form
Spell( 9634, { duration = INFINITY, type = "BUFF" }) -- Dire Bear Form
Spell( 1066, { duration = INFINITY, type = "BUFF" }) -- Aquatic Form
Spell( 24858, { duration = INFINITY, type = "BUFF" }) -- Moonkin Form
Spell( 17116, { duration = INFINITY, type = "BUFF", buffType = "Magic" }) -- Nature's Swiftness
Spell({ 1126, 5232, 5234, 6756, 8907, 9884, 9885 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Mark of the Wild
Spell({ 21849, 21850 }, { duration = 3600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Gift of the Wild
Spell( 19975, { duration = 12, buffType = "Magic" }) -- Nature's Grasp root
Spell({ 16689, 16810, 16811, 16812, 16813, 17329 }, { duration = 45, type = "BUFF", buffType = "Magic" }) -- Nature's Grasp
Spell( 16864, { duration = 600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Omen of Clarity
Spell( 16870, { duration = 15, type = "BUFF", buffType = "Magic" }) -- Clearcasting from OoC
Spell( 19675, { duration = 4 }) -- Feral Charge
Spell({ 467, 782, 1075, 8914, 9756, 9910 }, { duration = 600, type = "BUFF", buffType = "Magic" }) -- Thorns
Spell( 22812 ,{ duration = 15, type = "BUFF", buffType = "Magic" }) -- Barkskin
--SKIPPING: Hurricane (Channeled)
Spell({ 339, 1062, 5195, 5196, 9852, 9853 }, {
pvpduration = 20,
buffType = "Magic",
duration = function(spellID)
if spellID == 339 then return 12
elseif spellID == 1062 then return 15
elseif spellID == 5195 then return 18
elseif spellID == 5196 then return 21
elseif spellID == 9852 then return 24
else return 27 end
end
}) -- Entangling Roots
Spell({ 2908, 8955, 9901 }, { duration = 15 }) -- Soothe Animal
Spell({ 770, 778, 9749, 9907 }, { duration = 40 }) -- Faerie Fire
Spell({ 16857, 17390, 17391, 17392 }, { duration = 40 }) -- Faerie Fire (Feral)
Spell({ 2637, 18657, 18658 }, {
pvpduration = 20,
duration = function(spellID)
if spellID == 2637 then return 20
elseif spellID == 18657 then return 30
else return 40 end
end
}) -- Hibernate
Spell({ 99, 1735, 9490, 9747, 9898 }, { duration = 30 }) -- Demoralizing Roar
Spell({ 5211, 6798, 8983 }, { stacking = true, -- stacking?
duration = function(spellID)
local brutal_impact = Talent(16940, 16941)*0.5
if spellID == 5211 then return 2+brutal_impact
elseif spellID == 6798 then return 3+brutal_impact
else return 4+brutal_impact end
end
}) -- Bash
Spell( 5209, { duration = 6 }) -- Challenging Roar
Spell( 6795, { duration = 3, stacking = true }) -- Taunt
Spell({ 1850, 9821 }, { duration = 15, type = "BUFF" }) -- Dash
Spell( 5229, { duration = 10, type = "BUFF" }) -- Enrage
Spell({ 22842, 22895, 22896 }, { duration = 10, type = "BUFF" }) -- Frenzied Regeneration
Spell( 16922, { duration = 3 }) -- Imp Starfire Stun
Spell({ 9005, 9823, 9827 }, { -- Pounce stun doesn't create a debuff icon, so this is not going to be used
duration = function(spellID)
local brutal_impact = Talent(16940, 16941)*0.5
return 2+brutal_impact
end
}) -- Pounce
Spell({ 9007, 9824, 9826 }, { duration = 18, stacking = true, }) -- Pounce Bleed
Spell({ 8921, 8924, 8925, 8926, 8927, 8928, 8929, 9833, 9834, 9835 }, {
duration = function(spellID)
if spellID == 8921 then return 9
else return 12 end
end
}) -- Moonfire
Spell({ 1822, 1823, 1824, 9904 }, { duration = 9, stacking = true }) -- Rake
Spell({ 1079, 9492, 9493, 9752, 9894, 9896 }, { duration = 12, stacking = true }) -- Rip
Spell({ 5217, 6793, 9845, 9846 }, { name = "Tiger's Fury", duration = 6 })
Spell( 2893 ,{ duration = 8, type = "BUFF", buffType = "Magic" }) -- Abolish Poison
Spell( 29166 , { duration = 20, type = "BUFF", buffType = "Magic" }) -- Innervate
Spell({ 8936, 8938, 8939, 8940, 8941, 9750, 9856, 9857, 9858 }, { duration = 21, type = "BUFF", buffType = "Magic" }) -- Regrowth
Spell({ 774, 1058, 1430, 2090, 2091, 3627, 8910, 9839, 9840, 9841, 25299 }, { duration = 12, stacking = false, type = "BUFF", buffType = "Magic" }) -- Rejuv
Spell({ 5570, 24974, 24975, 24976, 24977 }, { duration = 12, stacking = true }) -- Insect Swarm
-------------
-- WARRIOR
-------------
Spell( 2457 , { duration = INFINITY, type = "BUFF" }) -- Battle Stance
Spell( 2458 , { duration = INFINITY, type = "BUFF" }) -- Berserker Stance
Spell( 71 , { duration = INFINITY, type = "BUFF" }) -- Def Stance
Spell({ 12294, 21551, 21552, 21553 }, { duration = 10 }) -- Mortal Strike Healing Reduction
Spell({72, 1671, 1672}, { duration = 6 }) -- Shield Bash
Spell( 18498, { duration = 3 }) -- Improved Shield Bash
Spell( 20230, { duration = 15, type = "BUFF" }) -- Retaliation
Spell( 1719, { duration = 15, type = "BUFF" }) -- Recklessness
Spell( 871, { type = "BUFF", duration = 10 }) -- Shield wall, varies
Spell( 12976, { duration = 20, type = "BUFF" }) -- Last Stand
Spell( 12328, { duration = 30 }) -- Death Wish
Spell({ 772, 6546, 6547, 6548, 11572, 11573, 11574 }, { stacking = true,
duration = function(spellID)
if spellID == 772 then return 9
elseif spellID == 6546 then return 12
elseif spellID == 6547 then return 15
elseif spellID == 6548 then return 18
else return 21 end
end
}) -- Rend
Spell( 12721, { duration = 12, stacking = true }) -- Deep Wounds
Spell({ 1715, 7372, 7373 }, { duration = 15 }) -- Hamstring
Spell( 23694 , { duration = 5 }) -- Improved Hamstring
Spell({ 6343, 8198, 8204, 8205, 11580, 11581 }, {
duration = function(spellID)
if spellID == 6343 then return 10
elseif spellID == 8198 then return 14
elseif spellID == 8204 then return 18
elseif spellID == 8205 then return 22
elseif spellID == 11580 then return 26
else return 30 end
end
}) -- Thunder Clap
Spell({ 694, 7400, 7402, 20559, 20560 }, { duration = 6 }) -- Mocking Blow
Spell( 1161 ,{ duration = 6 }) -- Challenging Shout
Spell( 355 ,{ duration = 3, stacking = true }) -- Taunt
Spell({ 5242, 6192, 6673, 11549, 11550, 11551, 25289 }, { type = "BUFF",
duration = function(spellID, isSrcPlayer)
local talents = isSrcPlayer and Talent(12321, 12835, 12836, 12837, 12838) or 0
return 120 * (1 + 0.1 * talents)
end
}) -- Battle Shout
Spell({ 1160, 6190, 11554, 11555, 11556 }, {
duration = function(spellID, isSrcPlayer)
local talents = isSrcPlayer and Talent(12321, 12835, 12836, 12837, 12838) or 0
return 30 * (1 + 0.1 * talents)
end
}) -- Demoralizing Shout, varies
Spell( 18499, { duration = 10, type = "BUFF" }) -- Berserker Rage
Spell({ 20253, 20614, 20615 }, { duration = 3 }) -- Intercept
Spell( 12323, { duration = 6 }) -- Piercing Howl
Spell( 5246, { duration = 8 }) -- Intimidating Shout Fear
Spell( 20511, { duration = 8 }) -- Intimidating Shout Main Target Cower Effect
Spell( 676 ,{
duration = function(spellID, isSrcPlayer)
local talents = isSrcPlayer and Talent(12313, 12804, 12807) or 0
return 10 + talents
end,
}) -- Disarm, varies
Spell( 29131 ,{ duration = 10, type = "BUFF" }) -- Bloodrage
Spell( 12798 , { duration = 3 }) -- Imp Revenge Stun
Spell( 2565 ,{ duration = 5, type = "BUFF" }) -- Shield Block, varies BUFF
Spell({ 7386, 7405, 8380, 11596, 11597 }, { duration = 30 }) -- Sunder Armor
Spell( 12809 ,{ duration = 5 }) -- Concussion Blow
Spell( 12292 ,{ duration = 20, type = "BUFF" }) -- Sweeping Strikes
Spell({ 12880, 14201, 14202, 14203, 14204 }, { duration = 12, type = "BUFF" }) -- Enrage
Spell({ 12966, 12967, 12968, 12969, 12970 }, { duration = 15, type = "BUFF" }) -- Flurry
Spell({ 16488, 16490, 16491 }, { duration = 6, type = "BUFF" }) -- Blood Craze
Spell(7922, { duration = 1 }) -- Charge
Spell(5530, { duration = 3 }) -- Mace Specialization
--------------
-- ROGUE
--------------
Spell( 14177 , { duration = INFINITY, type = "BUFF" }) -- Cold Blood
Spell({ 1784, 1785, 1786, 1787 } , { duration = INFINITY, type = "BUFF" }) -- Stealth
Spell( 14278 , { duration = 7, type = "BUFF" }) -- Ghostly Strike
Spell({ 16511, 17347, 17348 }, { duration = 15 }) -- Hemorrhage
Spell({ 11327, 11329 }, { duration = 10 }) -- Vanish
Spell({ 3409, 11201 }, { duration = 12 }) -- Crippling Poison
-- Spell({ 13218, 13222, 13223, 13224 }, { duration = 15 }) -- Wound Poison
-- Spell({ 2818, 2819, 11353, 11354, 25349 }, { duration = 12, stacking = true }) -- Deadly Poison
Spell({ 5760, 8692, 11398 }, {
duration = function(spellID)
if spellID == 5760 then return 10
elseif spellID == 8692 then return 12
else return 14 end
end
}) -- Mind-numbing Poison
Spell( 18425, { duration = 2 }) -- Improved Kick Silence
Spell( 13750, { duration = 15, type = "BUFF" }) -- Adrenaline Rush
Spell( 13877, { duration = 15, type = "BUFF" }) -- Blade Flurry
Spell( 1833, { duration = 4 }) -- Cheap Shot
Spell({ 2070, 6770, 11297 }, {
pvpduration = 20,
duration = function(spellID)
if spellID == 6770 then return 25 -- yes, Rank 1 spell id is 6770 actually
elseif spellID == 2070 then return 35
else return 45 end
end
}) -- Sap
Spell( 2094 , { duration = 10 }) -- Blind
Spell({ 8647, 8649, 8650, 11197, 11198 }, { duration = 30 }) -- Expose Armor
Spell({ 703, 8631, 8632, 8633, 11289, 11290 }, { duration = 18 }) -- Garrote
Spell({ 408, 8643 }, {
duration = function(spellID, isSrcPlayer, comboPoints)
local duration = spellID == 8643 and 1 or 0 -- if Rank 2, add 1s
if isSrcPlayer then
return duration + comboPoints
else
return duration + 5 -- just assume 5cp i guess
end
end
}) -- Kidney Shot
Spell({ 1943, 8639, 8640, 11273, 11274, 11275 }, { stacking = true,
duration = function(spellID, isSrcPlayer, comboPoints)
if isSrcPlayer then
return (6 + comboPoints*2)
else
return 16
end
end
}) -- Rupture
Spell({ 5171, 6774 }, { duration = nil, type = "BUFF" }) -- SnD, to prevent fallback to incorrect db values
Spell({ 2983, 8696, 11305 }, { duration = 15, type = "BUFF" }) -- Sprint
Spell( 5277 ,{ duration = 15, type = "BUFF" }) -- Evasion
Spell({ 1776, 1777, 8629, 11285, 11286 }, {
duration = function(spellID, isSrcPlayer)
if isSrcPlayer then
return 4 + 0.5*Talent(13741, 13793, 13792)
else
return 5.5
end
end
}) -- Gouge
Spell( 14251 , { duration = 6 }) -- Riposte (disarm)
------------
-- WARLOCK
------------
Spell({ 20707, 20762, 20763, 20764, 20765 }, { duration = 1800, type = "BUFF" }) -- Soulstone Resurrection
Spell({ 687, 696 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Demon SKin
Spell({ 706, 1086, 11733, 11734, 11735 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Demon Armor
Spell({ 18791 }, { duration = 1800, type = "BUFF", castFilter = true }) -- Touch of Shadow
Spell({ 18789 }, { duration = 1800, type = "BUFF", castFilter = true }) -- Burning Wish
Spell({ 18792 }, { duration = 1800, type = "BUFF", castFilter = true }) -- Fel Energy
Spell({ 18790 }, { duration = 1800, type = "BUFF", castFilter = true }) -- Fel Stamina
--SKIPPING: Drain Life, Mana, Soul, Enslave, Health funnel, kilrog
Spell( 24259 ,{ duration = 3 }) -- Spell Lock Silence
Spell({ 17767, 17850, 17851, 17852, 17853, 17854 }, { duration = 10 }) -- Consume Shadows (Voidwalker)
Spell( 18118, { duration = 5 }) -- Aftermath Proc
Spell({ 132, 2970, 11743 }, { duration = 600 }) -- Detect Invisibility
Spell( 5697, { duration = 600 }) -- Unending Breath
if class == "WARLOCK" then
Spell({ 17794, 17798, 17797, 17799, 17800 }, { duration = 12 }) -- Shadow Vulnerability (Imp Shadow Bolt)
end
Spell({ 18288 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Amplify Curse
Spell({ 1714, 11719 }, { duration = 30 }) -- Curse of Tongues
Spell({ 702, 1108, 6205, 7646, 11707, 11708 },{ duration = 120 }) -- Curse of Weakness
Spell({ 17862, 17937 }, { duration = 300 }) -- Curse of Shadows
Spell({ 1490, 11721, 11722 }, { duration = 300 }) -- Curse of Elements
Spell({ 704, 7658, 7659, 11717 }, { duration = 120 }) -- Curse of Recklessness
Spell( 603 ,{ duration = 60, stacking = true }) -- Curse of Doom
Spell( 18223 ,{ duration = 12 }) -- Curse of Exhaustion
Spell( 6358, {
duration = function(spellID, isSrcPlayer)
if isSrcPlayer then
local mul = 1 + Talent(18754, 18755, 18756)*0.1
return 15*mul
else
return 15
end
end
}) -- Seduction, varies, Improved Succubus
Spell({ 5484, 17928 }, {
duration = function(spellID)
return spellID == 5484 and 10 or 15
end
}) -- Howl of Terror
Spell({ 5782, 6213, 6215 }, {
pvpduration = 20,
duration = function(spellID)
if spellID == 5782 then return 10
elseif spellID == 6213 then return 15
else return 20 end
end
}) -- Fear
Spell({ 710, 18647 }, {
duration = function(spellID)
return spellID == 710 and 20 or 30
end
}) -- Banish
Spell({ 6789, 17925, 17926 }, { duration = 3 }) -- Death Coil
Spell({ 18265, 18879, 18880, 18881}, { duration = 30, stacking = true }) -- Siphon Life
if locale ~= "zhCN" or class ~= "MAGE" then
Spell({ 980, 1014, 6217, 11711, 11712, 11713 }, { duration = 24, stacking = true }) -- Curse of Agony
end
Spell({ 172, 6222, 6223, 7648, 11671, 11672, 25311 }, { stacking = true,
duration = function(spellID)
if spellID == 172 then
return 12
elseif spellID == 6222 then
return 15
else
return 18
end
end
})
Spell({ 348, 707, 1094, 2941, 11665, 11667, 11668, 25309 },{ duration = 15, stacking = true }) -- Immolate
Spell({ 6229, 11739, 11740, 28610 } ,{ duration = 30, type = "BUFF", buffType = "Magic" }) -- Shadow Ward
Spell({ 7812, 19438, 19440, 19441, 19442, 19443 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Sacrifice
Spell({ 17877, 18867, 18868, 18869, 18870, 18871 }, { duration = 5 }) -- Shadowburn Debuff
Spell( 18093 ,{ duration = 3 }) -- Pyroclasm
---------------
-- SHAMAN
---------------
Spell({ 8185, 10534, 10535 }, { duration = INFINITY, type = "BUFF" }) -- Fire Resistance Totem
Spell({ 8182, 10476, 10477 }, { duration = INFINITY, type = "BUFF" }) -- Frost Resistance Totem
Spell({ 10596, 10598, 10599 }, { duration = INFINITY, type = "BUFF" }) -- Nature Resistance Totem
Spell( 25909, { duration = INFINITY, type = "BUFF" }) -- Tranquil Air Totem
Spell({ 5672, 6371, 6372, 10460, 10461 }, { duration = INFINITY, type = "BUFF" }) -- Healing Stream Totem
Spell({ 5677, 10491, 10493, 10494 }, { duration = INFINITY, type = "BUFF" }) -- Mana Spring Totem
Spell({ 8076, 8162, 8163, 10441, 25362 }, { duration = INFINITY, type = "BUFF" }) -- Strength of Earth Totem
Spell({ 8836, 10626, 25360 }, { duration = INFINITY, type = "BUFF" }) -- Grace of Air Totem
Spell({ 8072, 8156, 8157, 10403, 10404, 10405 }, { duration = INFINITY, type = "BUFF" }) -- Stoneskin Totem
Spell({ 16191, 17355, 17360 }, { duration = 12, type = "BUFF" }) -- Mana Tide Totem
Spell( 8178 ,{ duration = 45, type = "BUFF" }) -- Grounding Totem Effect, no duration, but lasts 45s. Keeping for enemy buffs
-- Using Druid's NS
-- Spell( 16188, { duration = INFINITY, type = "BUFF" }) -- Nature's Swiftness
Spell({ 324, 325, 905, 945, 8134, 10431, 10432 }, { duration = 600, type = "BUFF", buffType = "Magic" }) -- Lightning Shield
Spell( 546 ,{ duration = 600, type = "BUFF", buffType = "Magic" }) -- Water Walking
Spell( 131 ,{ duration = 600, type = "BUFF", buffType = "Magic" }) -- Water Breahing
Spell({ 16257, 16277, 16278, 16279, 16280 }, { duration = 15, type = "BUFF" }) -- Flurry
Spell( 17364 ,{ duration = 12 }) -- Stormstrike
Spell({ 16177, 16236, 16237 }, { duration = 15, type = "BUFF", buffType = "Magic" }) -- Ancestral Fortitude from Ancestral Healing
Spell({ 8056, 8058, 10472, 10473 }, { duration = 8 }) -- Frost Shock
Spell({ 8050, 8052, 8053, 10447, 10448, 29228 }, { duration = 12, stacking = true }) -- Flame Shock
Spell( 29203 ,{ duration = 15, type = "BUFF", buffType = "Magic" }) -- Healing Way
Spell({ 8034, 8037, 10458, 16352, 16353 }, { duration = 8 }) -- Frostbrand Attack
Spell( 3600 ,{ duration = 5 }) -- Earthbind Totem
--------------
-- PALADIN
--------------
Spell( 19746, { duration = INFINITY, type = "BUFF" }) -- Concentration Aura
Spell({ 465, 643, 1032, 10290, 10291, 10292, 10293 }, { duration = INFINITY, type = "BUFF" }) -- Devotion Aura
Spell({ 19891, 19899, 19900 }, { duration = INFINITY, type = "BUFF" }) -- Fire Resistance Aura
Spell({ 19888, 19897, 19898 }, { duration = INFINITY, type = "BUFF" }) -- Frost Resistance Aura
Spell({ 19876, 19895, 19896 }, { duration = INFINITY, type = "BUFF" }) -- Shadow Resistance Aura
Spell({ 7294, 10298, 10299, 10300, 10301 }, { duration = INFINITY, type = "BUFF" }) -- Retribution Aura
Spell( 25780, { duration = 1800, type = "BUFF", buffType = "Magic" }) -- Righteous Fury
Spell({ 19740, 19834, 19835, 19836, 19837, 19838, 25291 }, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Might
Spell({ 25782, 25916 }, { duration = 900, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Greater Blessing of Might
Spell({ 19742, 19850, 19852, 19853, 19854, 25290 }, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Wisdom
Spell({ 25894, 25918 }, { duration = 900, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Greater Blessing of Might
Spell(20217, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Kings
Spell(25898, { duration = 900, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Greater Blessing of Kings
Spell({ 20911, 20912, 20913 }, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Sanctuary
Spell(25899, { duration = 900, type = "BUFF", castFilter = tru, buffType = "Magic" }) -- Greater Blessing of Sanctuary
Spell(1038, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Salvation
Spell(25895, { duration = 900, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Greater Blessing of Salvation
Spell({ 19977, 19978, 19979 }, { duration = 300, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Blessing of Light
Spell(25890, { duration = 900, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Greater Blessing of Light
Spell( 20066, { duration = 6 }) -- Repentance
Spell({ 2878, 5627, 5627 }, {
duration = function(spellID)
if spellID == 2878 then return 10
elseif spellID == 5627 then return 15
else return 20 end
end
}) -- Turn Undead
Spell( 1044, { duration = 10, type = "BUFF", buffType = "Magic" }) -- Blessing of Freedom
Spell({ 6940, 20729 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Blessing of Sacrifice
Spell({ 1022, 5599, 10278 }, { type = "BUFF",
buffType = "Magic",
duration = function(spellID)
if spellID == 1022 then return 6
elseif spellID == 5599 then return 8
else return 10 end
end
}) -- Blessing of Protection
Spell(25771, { duration = 60 }) -- Forbearance
Spell({ 498, 5573 }, { type = "BUFF",
duration = function(spellID)
return spellID == 498 and 6 or 8
end
}) -- Divine Protection
Spell({ 642, 1020 }, { type = "BUFF",
duration = function(spellID)
return spellID == 642 and 10 or 12
end
}) -- Divine Shield
Spell({ 20375, 20915, 20918, 20919, 20920 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of Command
Spell({ 21084, 20287, 20288, 20289, 20290, 20291, 20292, 20293 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of Righteousness
Spell({ 20162, 20305, 20306, 20307, 20308, 21082 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of the Crusader
Spell({ 20165, 20347, 20348, 20349 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of Light
Spell({ 20166, 20356, 20357 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of Wisdom
Spell( 20164 , { duration = 30, type = "BUFF", buffType = "Magic" }) -- Seal of Justice
Spell({ 21183, 20188, 20300, 20301, 20302, 20303 }, { duration = 10 }) -- Judgement of the Crusader
Spell({ 20185, 20344, 20345, 20346 }, {
duration = function(spellID, isSrcPlayer)
if isSrcPlayer then
local talents = 10*Talent(20359, 20360, 20361)
return 10+talents
else
return 10
end
end
}) -- Judgement of Light
Spell({ 20186, 20354, 20355 }, {
duration = function(spellID, isSrcPlayer)
if isSrcPlayer then
local talents = 10*Talent(20359, 20360, 20361)
return 10+talents
else
return 10
end
end
}) -- Judgement of Wisdom
Spell(20184, { duration = 10 }) -- Judgement of Justice
Spell({ 853, 5588, 5589, 10308 }, {
duration = function(spellID)
if spellID == 853 then return 3
elseif spellID == 5588 then return 4
elseif spellID == 5589 then return 5
else return 6 end
end
}) -- Hammer of Justice
Spell({ 20925, 20927, 20928 }, { duration = 10, type = "BUFF", buffType = "Magic" }) -- Holy Shield
Spell({ 20128, 20131, 20132, 20133, 20134 }, { duration = 10, type = "BUFF" }) -- Redoubt
Spell({ 67, 26017, 26018 }, { duration = 10, type = "BUFF", buffType = "Magic" }) -- Vindication
Spell({ 20050, 20052, 20053, 20054, 20055 }, { duration = 8, type = "BUFF", buffType = "Magic" }) -- Vengeance
Spell( 20170 ,{ duration = 2 }) -- Seal of Justice stun
-------------
-- HUNTER
-------------
Spell( 13161, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Beast
Spell( 5118, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Cheetah
Spell( 13159, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Pack
Spell( 13163, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Monkey
Spell({ 20043, 20190 }, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Wild
Spell({ 13165, 14318, 14319, 14320, 14321, 14322, 25296 }, { duration = INFINITY, type = "BUFF" }) -- Aspect of the Hawk
Spell( 5384, { duration = INFINITY, type = "BUFF" }) -- Feign Death (Will it work?)
Spell({ 19506, 20905, 20906 }, { duration = 1800, type = "BUFF", castFilter = true }) -- Trueshot Aura
Spell(19615, { duration = 8, type = "BUFF" }) -- Frenzy
Spell({ 1130, 14323, 14324, 14325 }, { duration = 120 }) -- Hunter's Mark
Spell(19263, { duration = 10, type = "BUFF" }) -- Deterrence
Spell(3045, { duration = 15, type = "BUFF" }) -- Rapid Fire
Spell(19574, { duration = 18, type = "BUFF" }) -- Bestial Wrath
Spell({ 1978, 13549, 13550, 13551, 13552, 13553, 13554, 13555, 25295 }, { duration = 15, stacking = true }) -- Serpent Sting
Spell({ 3043, 14275, 14276, 14277 }, { duration = 20 }) -- Scorpid Sting
Spell({ 3034, 14279, 14280 }, { duration = 8 }) -- Viper Sting
Spell({ 19386, 24132, 24133 }, { duration = 12 }) -- Wyvern Sting
Spell({ 24131, 24134, 24135 }, { duration = 12 }) -- Wyvern Sting Dot
Spell({ 1513, 14326, 14327 }, {
pvpduration = 20,
duration = function(spellID)
if spellID == 1513 then return 10
elseif spellID == 14326 then return 15
else return 20 end
end
}) -- Scare Beast
Spell(19229, { duration = 5 }) -- Wing Clip Root
Spell({ 19306, 20909, 20910 }, { duration = 5 }) -- Counterattack
-- Spell({ 13812, 14314, 14315 }, { duration = 20, stacking = true }) -- Explosive Trap
Spell({ 13797, 14298, 14299, 14300, 14301 }, { duration = 15, stacking = true }) -- Immolation Trap
Spell({ 3355, 14308, 14309 }, {
pvpduration = 20,
duration = function(spellID, isSrcPlayer)
local mul = 1
if isSrcPlayer then
mul = mul + 0.15*Talent(19239, 19245) -- Clever Traps
end
if spellID == 3355 then return 10*mul
elseif spellID == 14308 then return 15*mul
else return 20*mul end
end
}) -- Freezing Trap
Spell(19503, { duration = 4 }) -- Scatter Shot
Spell({ 2974, 14267, 14268 }, { duration = 10 }) -- Wing Clip
Spell(5116, { duration = 4 }) -- Concussive Shot
Spell(19410, { duration = 3 }) -- Conc Stun
Spell(24394, { duration = 3 }) -- Intimidation
-- Spell(15571, { duration = 4 }) -- Daze from Aspect
Spell(19185, { duration = 5 }) -- Entrapment
Spell(25999, { duration = 1 }) -- Boar Charge
Spell(1002, { duration = 60 }) -- Eye of the Beast
Spell(1539, { duration = 20 }) -- Feed Pet Effect
Spell({ 136, 3111, 3661, 3662, 13542, 13543, 13544 }, { duration = 5, type = "BUFF" }) -- Mend Pet
-------------
-- MAGE
-------------
Spell( 12043, { duration = INFINITY, type = "BUFF", buffType = "Magic" }) -- Presence of Mind
Spell({ 1459, 1460, 1461, 10156, 10157 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Arcane Intellect
Spell( 23028, { duration = 3600, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Arcane Brilliance
Spell({ 6117, 22782, 22783 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Mage Armor
Spell({ 168, 7300, 7301 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Frost Armor
Spell({ 7302, 7320, 10219, 10220 }, { duration = 1800, type = "BUFF", castFilter = true, buffType = "Magic" }) -- Ice Armor
Spell( 2855, { duration = 120, type = "BUFF", buffType = "Magic" }) -- Detect Magic
Spell( 130, { duration = 1800, type = "BUFF", buffType = "Magic" }) -- Slow Fall
Spell({ 133, 143, 145, 3140, 8400, 8401, 8402, 10148, 10149, 10150, 10151, 25306 }, {
stacking = true,
duration = function(spellID)
if spellID == 133 then return 4
elseif spellID == 143 then return 6
elseif spellID == 145 then return 6
else return 8 end
end
}) -- Fireball
Spell({ 11366, 12505, 12522, 12523, 12524, 12525, 12526, 18809 }, { duration = 12, stacking = true }) -- Pyroblast
Spell({ 604, 8450, 8451, 10173, 10174 }, { duration = 600, type = "BUFF", buffType = "Magic" }) -- Dampen Magic
Spell({ 1008, 8455, 10169, 10170 }, { duration = 600, type = "BUFF", buffType = "Magic" }) -- Amplify Magic
Spell(18469, { duration = 4 }) -- Imp CS Silence
Spell({ 118, 12824, 12825, 12826, 28270, 28271, 28272 }, {
pvpduration = 20,
duration = function(spellID)
if spellID == 118 then return 20
elseif spellID == 12824 then return 30
elseif spellID == 12825 then return 40
else return 50 end
end
}) -- Polymorph
Spell(11958, { duration = 10, type = "BUFF" }) -- Ice Block
Spell({ 1463, 8494, 8495, 10191, 10192, 10193 }, { duration = 60, type = "BUFF", buffType = "Magic" }) -- Mana Shield
Spell({ 11426, 13031, 13032, 13033 }, { duration = 60, type = "BUFF", buffType = "Magic" }) -- Ice Barrier
Spell({ 543, 8457, 8458, 10223, 10225 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Fire Ward
Spell({ 6143, 8461, 8462, 10177, 28609 }, { duration = 30, type = "BUFF", buffType = "Magic" }) -- Frost Ward
Spell(12355, { duration = 2 }) -- Impact
Spell(12654, { duration = 4 }) -- Ignite
if class == "MAGE" then
Spell(22959, {
duration = function(spellID, isSrcPlayer)
if Talent(11095, 12872, 12873) > 0 then
return 30
else
return nil
end
end }) -- Fire Vulnerability
end
if class == "MAGE" then
Spell(12579, {
duration = function(spellID, isSrcPlayer)
if Talent(11180, 28592, 28593, 28594, 28595) > 0 then
return 15
else
return nil
end
end }) -- Winter's Chill
end
Spell({ 11113, 13018, 13019, 13020, 13021 }, { duration = 6 }) -- Blast Wave
Spell({ 2120, 2121, 8422, 8423, 10215, 10216 }, { duration = 8, stacking = true }) -- Flamestrike
Spell({ 120, 8492, 10159, 10160, 10161 }, {
duration = function(spellID, isSrcPlayer)
local permafrost = isSrcPlayer and Talent(11175, 12569, 12571) or 0
return 8 + permafrost
end
}) -- Cone of Cold
if class == "MAGE" then
-- Chilled from Imp Blizzard
Spell({ 12484, 12485, 12486 }, {
duration = function(spellID, isSrcPlayer)
if Talent(11185, 12487, 12488) > 0 then -- Don't show anything if mage doesn't have imp blizzard talent
local permafrost = Talent(11175, 12569, 12571) -- Always count player's permafost, even source isn't player.
return 1.5 + permafrost + 0.5
-- 0.5 compensates for delay between damage event and slow application
else
return nil
end
end
}) -- Improved Blizzard (Chilled)
-- Manually setting a custom spellname for ImpBlizzard's "Chilled" aura
lib.spellNameToID["ImpBlizzard"] = 12486
-- Frost Armor will overwrite Chilled to 7321 right after
end
Spell({6136, 7321}, {
duration = function(spellID, isSrcPlayer)
local permafrost = isSrcPlayer and Talent(11175, 12569, 12571) or 0
return 5 + permafrost
end
}) -- Frost/Ice Armor (Chilled)
Spell({ 116, 205, 837, 7322, 8406, 8407, 8408, 10179, 10180, 10181, 25304 }, {
duration = function(spellID, isSrcPlayer)
local permafrost = isSrcPlayer and Talent(11175, 12569, 12571) or 0
if spellID == 116 then return 5 + permafrost
elseif spellID == 205 then return 6 + permafrost
elseif spellID == 837 then return 6 + permafrost
elseif spellID == 7322 then return 7 + permafrost
elseif spellID == 8406 then return 7 + permafrost
elseif spellID == 8407 then return 8 + permafrost
elseif spellID == 8408 then return 8 + permafrost
else return 9 + permafrost end
end
}) -- Frostbolt
Spell(12494, { duration = 5 }) -- Frostbite
Spell({ 122, 865, 6131, 10230 }, { duration = 8 }) -- Frost Nova
-- Spell(12536, { duration = 15 }) -- Clearcasting
Spell(12043, { duration = 15 }) -- Presence of Mind
Spell(12042, { duration = 15 }) -- Arcane Power
Spell(12051, { duration = 8, type = "BUFF" }) -- Evocation
lib:SetDataVersion(Type, Version)
|
local M = {}
local cursors = {}
local get_default_cache_path = function()
local HOME = os.getenv('HOME')
local XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME')
local BASE = XDG_CACHE_HOME or HOME
return BASE .. '/.vis-cursors'
end
M.path = get_default_cache_path()
local apply_cursor_pos = function(win)
if win.file == nil or win.file.path == nil then
return
end
local pos = cursors[win.file.path]
if pos == nil then
return
end
win.selection.pos = tonumber(pos)
vis:feedkeys("zz")
end
local read_cursors = function()
local f = io.open(M.path)
if f == nil then
return
end
-- read cursor positions per file path
local prev_dir
for line in f:lines() do
for path, pos in string.gmatch(line, '(.+)[,%s](%d+)') do
-- uncompress prev dir if '@'
local repeat_dir = string.match(path, '^%@')
if repeat_dir then
local filename = string.match(path, '^.*/(.*)')
path = prev_dir .. filename
else
local dir = string.match(path, '(.*/)')
prev_dir = dir
end
-- only set cursor paths not already set in the current process
if not cursors[path] then
cursors[path] = pos
end
end
end
f:close()
end
local write_cursors = function()
-- read cursors file in case other vis processes updated it
read_cursors()
local f = io.open(M.path, 'w+')
if f == nil then
return
end
-- sort paths
local paths = {}
for path in pairs(cursors) do
table.insert(paths, path)
end
table.sort(paths)
-- buffer cursors string
local t = {}
local prev_dir
for i, path in ipairs(paths) do
local dir = string.match(path, '(.*/)')
-- compress dir to just '@' if same as prev dir
if dir == prev_dir then
local filename = string.match(path, '^.*/(.*)')
table.insert(t, string.format('@/%s,%d', filename, cursors[path]))
else
prev_dir = dir
table.insert(t, string.format('%s,%d', path, cursors[path]))
end
end
local s = table.concat(t, '\n')
f:write(s)
f:close()
end
local set_cursor_pos = function(win)
if win.file == nil or win.file.path == nil then
return
end
-- set cursor pos for current file path
cursors[win.file.path] = win.selection.pos
end
vis.events.subscribe(vis.events.INIT, read_cursors)
vis.events.subscribe(vis.events.WIN_OPEN, apply_cursor_pos)
vis.events.subscribe(vis.events.WIN_CLOSE, set_cursor_pos)
vis.events.subscribe(vis.events.QUIT, write_cursors)
return M
|
posX = 0
posY = 0
ID = 0
macroF = 0
timeRes = 0
maxCap = 0 -- maximum capacity
coop = 0 -- mode
comScope = 0 -- comunication scope
time = 0 -- time passed
cap = 202 -- current capacity
startup = 1 -- to spawn the
cId = 0 -- company id
bId = 0 -- base id
explorers = 0
transporters = 0
deliveryOre = 0 -- ore delivered every time
function initAuton(x, y, id, macroFactor, timeResolution , C , M, CS, T, CID ,BID, DeliveryOre)
cId = CID
bId=BID
coop = M
comScope = CS
time = T
maxCap = C
posX = 100
posY = 100
ID = id
macroF = macroFactor
timeRes = timeResolution
deliveryOre = DeliveryOre
l_debug("Agent #: " .. id .. " has been initialized")
--l_debug("BaseID: "..bId)
end
-- Event Handling:
function handleEvent(origX, origY, eventID,eventDesc , eventTable)
--function handleEvent(origX, origY, origID, origDesc, eventTable)
loadstring("msg="..eventTable)()
if l_distance(posX, posY, origX, origY) > comScope or msg.companyId ~= cId then -- check if in range of scope and id
return 0 ,0 ,0 , "null"
elseif eventDesc == "explorer" then
if msg.msg_value=="back" then increaseAutonCounter("e") end
elseif eventDesc == "transporter" then
if masg.msg_type== "back" then increaseAutonCounter("t") end
elseif msg.msg_type == "delivery" and msg.msg_value > 0 then
increaseCap(deliveryOre)
l_debug("Base #"..bId..": I got "..msg.msg_value.." Ore sample(s), now having "..cap.."/"..maxCap)
end
return 0 ,0 ,0 , "null"
end
function initiateEvent()
--l_debug(startup)
if startup == 1 then
-- start form the base
calltable = {baseId = bId, companyId = cId, msg_type = "initiate", msg_value = ""}
l_debug("STARTUP")
l_debug(intToMsg(posX,posY))
startup = 0
elseif cap>=maxCap then
calltable = {baseId = bId,companyId = cId, msg_type = "full",msg_value=""}
--l_debug("cap reached")
--else
-- --l_debug("give base loc")
-- calltable = {baseId = bId, companyId = cId, msg_type = "location", msg_value = intToMsg(posX,posY)}
end
propagationSpeed = 0
targetID = 0; -- broadcast to all
eventDesc = "base"
s_calltable = serializeTbl(calltable)
return propagationSpeed, s_calltable, eventDesc, targetID
end
function getSyncData()
return posX, posY
end
function simDone()
l_debug("Base #: " .. ID .. " is done")
l_debug("ore collected: " .. cap)
l_debug("explorers returned: " .. explorers)
l_debug("collectors returned: " .. transporters )
-- l_debug(cId)
-- l_debug(coop)
-- l_debug(comScope)
-- l_debug(time)
-- l_debug(maxCap)
-- l_debug(posX)
-- l_debug(posY)
-- l_debug(ID)
-- l_debug(macroF)
-- l_debug(timeRes)
-- l_debug(deliveryOre)
end
function serializeTbl(val, name, depth)
--skipnewlines = skipnewlines or false
depth = depth or 0
local tbl = string.rep("", depth)
if name then
if type(name)=="number" then
namestr = "["..name.."]"
tbl= tbl..namestr.."="
elseif name then
tbl = tbl ..name.."="
end
end
if type(val) == "table" then
tbl = tbl .. "{"
local i = 1
for k, v in pairs(val) do
if i ~= 1 then
tbl = tbl .. ","
end
tbl = tbl .. serializeTbl(v,k, depth +1)
i = i + 1;
end
tbl = tbl .. string.rep(" ", depth) .. "}"
elseif type(val) == "number" then
tbl = tbl .. tostring(val)
elseif type(val) == "string" then
tbl = tbl .. string.format("%q", val)
else
tbl = tbl .. "[datatype not serializable:".. type(val) .. "]"
end
return tbl
end
function increaseCap(int)
cap=cap+int
if cap > maxCap then
cap = maxCap
end
end
function increaseAutonCounter(char)
if char=="t" then transporters=transporters+1 end
if char=="e" then explorers=explorers+1 end
end
function intToMsg(int,int2)
a=""
b=""
if int<10 then
a="00"..tostring(int)
elseif int<100 then
a="0"..tostring(int)
else
a=tostring(int)
end
if int2<10 then
b="00"..tostring(int2)
elseif int2<100 then
b="0"..tostring(int2)
else
b=tostring(int2)
end
return a..b
end |
--[[============================================================
--=
--= LuaCss - CSS Tokenizing & Minimizing
--= https://github.com/ReFreezed/LuaCss
--=
--= References:
--= - https://www.w3.org/TR/css-syntax-3/
--= - https://drafts.csswg.org/cssom/ (Editor's draft, 2018-05-17)
--=
--= MIT License:
--= Copyright © 2018 Marcus 'ReFreezed' Thunström
--=
--= 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.
--=
--==============================================================
API
--------------------------------
minimize
cssString = minimize( cssString [, options ] )
tokens = minimize( tokens [, options ] )
serialize
cssString = serialize( tokens [, options ] )
serializeAndMinimize
cssString = serializeAndMinimize( tokens [, options ] )
tokenize
tokens = tokenize( cssString )
Options
--------------------------------
autoZero
Convert '0px' and '0%' etc. to a simple '0' during minification.
strict
Trigger an error when a badString or badUrl token is encountered during minification.
--============================================================]]
local CP_NULL = 0x00
local CP_DASH = 0x2D
local CP_0 = 0x30
local CP_9 = 0x39
local CP_A = 0x41
local CP_Z = 0x5A
local CP_BACKSLASH = 0x5C
local CP_UNDERSCORE = 0x5F
local CP_a = 0x61
local CP_z = 0x7A
local CP_DELETE = 0x7F
local CP_REPLACE = 0xFFFD
local CP_NONASCII_START = 0x80
local CHAR_REPLACE = "\239\191\189"
local path = ("."..assert(...,"Needs module path.")):gsub("[^.]+$","")
local utf8 = require((path.."utf8"):sub(2))
local F = string.format
local css = {_VERSION="1.0.0"}
--==============================================================
--= Utilities ==================================================
--==============================================================
local findEnd
local getKeys
local indexOf
local inRange
local isAny
local isNumberToken
local isValidCodepoint, isControlCharacterCodepoint, isSurrogateCodepoint
local makeString
local newTokenComment, newTokenWhitespace, newTokenNumber
local printobj
local round, clamp
local sort
local sortNatural, compareNatural
local substrCompareAsciiChar, substrCompareBytes
function indexOf(t, v)
for i, item in ipairs(t) do
if item == v then return i end
end
return nil
end
-- printobj( ... )
-- Note: Does not write to log.
do
local out = io.stdout
local _tostring = tostring
local function tostring(v)
return (_tostring(v):gsub('^table: ', ''))
end
local function compareKeys(a, b)
return compareNatural(tostring(a), tostring(b))
end
local function _printobj(v, tables)
local vType = type(v)
if vType == "table" then
if tables[v] then
out:write(tostring(v), " ")
return
end
out:write(tostring(v), "{ ")
tables[v] = true
local indices = {}
for i = 1, #v do indices[i] = true end
for _, k in ipairs(sort(getKeys(v), compareKeys)) do
if not indices[k] then
out:write(tostring(k), "=")
_printobj(v[k], tables)
end
end
for i = 1, #v do
out:write(i, "=")
_printobj(v[i], tables)
end
out:write("} ")
elseif vType == "number" then
out:write(F("%g ", v))
elseif vType == "string" then
out:write('"', v:gsub("%z", "\\0"):gsub("\n", "\\n"), '" ')
else
out:write(tostring(v), " ")
end
end
function printobj(...)
for i = 1, select("#", ...) do
if i > 1 then out:write("\t") end
_printobj(select(i, ...), {})
end
out:write("\n")
end
end
function sort(t, ...)
table.sort(t, ...)
return t
end
-- array = sortNatural( array [, attribute ] )
do
local function pad(numStr)
return F("%03d%s", #numStr, numStr)
end
function compareNatural(a, b)
return tostring(a):gsub("%d+", pad) < tostring(b):gsub("%d+", pad)
end
function sortNatural(t, k)
if k then
table.sort(t, function(a, b)
return compareNatural(a[k], b[k])
end)
else
table.sort(t, compareNatural)
end
return t
end
end
function getKeys(t)
local keys = {}
for k in pairs(t) do
table.insert(keys, k)
end
return keys
end
function inRange(n, min, max)
return n >= min and n <= max
end
function isValidCodepoint(cp)
return cp >= 0 and cp <= 0x10FFFF
end
function isControlCharacterCodepoint(cp)
return inRange(cp, 0x01, 0x1F)
end
function isSurrogateCodepoint(cp)
return cp >= 0xD800 and cp <= 0xDFFF
end
function substrCompareAsciiChar(s, i, chars)
local c = s:sub(i, i)
if c == "" then return false end
return chars:find(c, 1, true) ~= nil
--[[
local b = s:byte(i)
for charIndex = 1, #chars do
if b == chars:byte(charIndex) then
return true
end
end
return false
]]
end
--[[
-- endIndex = substrCompareBytes( string, startIndex, comparison )
function substrCompareBytes(s, i, comparison) -- Not used.
if i < 1 or i > #s-#comparison+1 then return nil end
for offset = 0, #comparison-1 do
if s:byte(i+offset) ~= comparison:byte(1+offset) then
return nil
end
end
return i+#comparison-1
end
]]
function findEnd(s, ...)
local _, i = s:find(...)
return i
end
do
local UNPACK_LIMIT = 8000
local chars = {}
function makeString(cps)
if not cps[UNPACK_LIMIT] then
return utf8.char(unpack(cps))
end
local toChar = utf8.char
for i = 1, #cps do
chars[i] = toChar(cps[i])
assert(#chars[i] == 1)
end
return table.concat(chars, "", 1, #cps)
end
--[[ Test limit of unpack(). (Is this always the same though?)
for i = 1, math.huge do
chars[i] = true
if not pcall(unpack, chars) then
print("Max unpacks: "..i)
os.exit(1)
end
end
--]]
end
-- token = newTokenComment( [ comment="" ] )
function newTokenComment(comment)
local token = {type="comment"}
token.value = comment or ""
return token
end
-- token = newTokenWhitespace( [ value="" ] )
function newTokenWhitespace(value)
local token = {type="whitespace"}
token.value = value or ""
return token
end
-- token = newTokenNumber( [ number=0, numberRepresentation=auto, numberType=auto ] )
function newTokenNumber(n, nRepr, nType)
local token = {type="number"}
n = n or 0
nRepr = nRepr or F("%g ", n)
token.representation = nRepr
token.value = n
token.numberType = nType or nRepr:find"[^%d]" and "number" or "integer"
return token
end
function isAny(v, ...)
for i = 1, select("#", ...) do
if v == select(i, ...) then return true end
end
return false
end
function isNumberToken(token)
return token ~= nil and isAny(token.type, "dimension","percentage","number")
end
function round(n)
return math.floor(n+0.5)
end
function clamp(n, nMin, nMax)
return math.min(math.max(n, nMin), nMax)
end
--==============================================================
--= Tokenizer ==================================================
--==============================================================
local isEscapeStart
local isNameStart
local isIdentStart
local isNumberStart
local isName
local matchWs
local matchAlphaOrNonAscii
local matchNonPrintable
local matchPrintable
local consumeNumericToken
local consumeIdentLikeToken
local consumeStringToken
local consumeUrlToken
local consumeUnicodeRangeToken
local consumeEscape
local consumeName
local consumeNumber
local consumeRemnantsOfBadUrl
local consumeWhitespace
local consumeComment
function isEscapeStart(s, ptr)
if not substrCompareAsciiChar(s, ptr, "\\") then return false end
if substrCompareAsciiChar(s, ptr+1, "\n") then return false end
return true
end
function isNameStart(s, ptr)
return matchAlphaOrNonAscii(s, ptr) ~= nil
end
function isIdentStart(s, ptr)
if substrCompareAsciiChar(s, ptr, "-") then
return isNameStart(s, ptr+1) or isEscapeStart(s, ptr+1)
elseif isNameStart(s, ptr) then
return true
elseif substrCompareAsciiChar(s, ptr, "\\") then
return isEscapeStart(s, ptr)
else
return false
end
end
function isNumberStart(s, ptr)
if substrCompareAsciiChar(s, ptr, "+-") then
if substrCompareAsciiChar(s, ptr+1, "0123456789") then
return true
elseif s:find("^%.%d", ptr+1) then
return true
else
return false
end
elseif substrCompareAsciiChar(s, ptr, ".") then
return substrCompareAsciiChar(s, ptr+1, "0123456789")
elseif substrCompareAsciiChar(s, ptr, "0123456789") then
return true
else
return false
end
end
function isName(s, ptr)
return isNameStart(s, ptr) or substrCompareAsciiChar(s, ptr, "0123456789-")
end
-- ws*
function matchWs(s, ptr)
return s:find("^[ \t\n]*", ptr)
end
function matchAlphaOrNonAscii(s, ptr)
if s:find("^[%a_]", ptr) then return ptr, ptr end
local cp = utf8.codepoint(s, 1, 1, ptr)
if not cp or cp < CP_NONASCII_START then return nil end
return ptr, ptr+utf8.charlen(s, ptr)-1
end
function matchNonPrintable(s, ptr)
if not s:find("^[%z\1-\8\11\14-\31\127]", ptr) then return nil end
return ptr, ptr
end
-- function matchPrintable(s, ptr) -- Not used.
-- if not s:find("^[^%z\1-\8\11\14-\31\127]", ptr) then return nil end
-- return ptr, ptr
-- end
function consumeNumericToken(s, ptr)
local nRepr, n, nType
nRepr, n, nType, ptr = consumeNumber(s, ptr)
local token
if isIdentStart(s, ptr) then
token = {type="dimension"}
token.unit, ptr = consumeName(s, ptr)
elseif substrCompareAsciiChar(s, ptr, "%") then
token = {type="percentage"}
ptr = ptr+1
else
token = newTokenNumber(n, nRepr, nType)
return token, ptr
end
token.representation = nRepr
token.value = n
token.numberType = nType
return token, ptr
end
function consumeIdentLikeToken(s, ptr)
local name
name, ptr = consumeName(s, ptr)
local token
if #name == 3 and substrCompareAsciiChar(s, ptr, "(") and name:lower() == "url" then
token, ptr = consumeUrlToken(s, ptr+1) -- Note the previous consumption.
elseif substrCompareAsciiChar(s, ptr, "(") then
token, ptr = {type="function"}, ptr+1
token.value = name
else
token = {type="ident"}
token.value = name
end
return token, ptr
end
function consumeStringToken(s, ptr, quoteChar)
-- Assume the initial quoteChar has been consumed.
local cps = {}
while true do
if ptr > #s or substrCompareAsciiChar(s, ptr, quoteChar) then
local token = {type="string"}
token.value = makeString(cps)
token.quoteCharacter = quoteChar
return token, ptr+1
elseif substrCompareAsciiChar(s, ptr, "\n") then
print("[css] Parse error: Invalid newline at position "..ptr..".")
local token = {type="badString"}
return token, ptr
elseif substrCompareAsciiChar(s, ptr, "\\") then
if ptr+1 > #s then
-- void
elseif substrCompareAsciiChar(s, ptr+1, "\n") then
ptr = ptr+2
elseif isEscapeStart(s, ptr) then
local cp
cp, ptr = consumeEscape(s, ptr+1)
table.insert(cps, cp)
else
assert(false) -- Unspecified syntax.
end
else
local cp = utf8.codepoint(s, 1, 1, ptr)
table.insert(cps, cp)
ptr = ptr+utf8.charlen(s, ptr)
end
end
end
function consumeUrlToken(s, ptr)
-- Assume the initial "url(" has been consumed.
local from, to = matchWs(s, ptr)
ptr = to+1
if ptr > #s then
local token = {type="url"}
token.value = ""
token.quoteCharacter = ""
return token, ptr
end
if substrCompareAsciiChar(s, ptr, "\"'") then
local quoteChar = s:sub(ptr, ptr)
local strToken
strToken, ptr = consumeStringToken(s, ptr+1, quoteChar)
if strToken.type == "badString" then
ptr = consumeRemnantsOfBadUrl(s, ptr)
local token = {type="badUrl"}
return token, ptr
end
local from, to = matchWs(s, ptr)
ptr = to+1
if ptr > #s or substrCompareAsciiChar(s, ptr, ")") then
local token = {type="url"}
token.value = strToken.value
token.quoteCharacter = quoteChar
if token.value:find"^data:image/jpeg;base64," then
token.value = token.value:gsub("%s+", "")
end
return token, ptr+1
else
ptr = consumeRemnantsOfBadUrl(s, ptr)
local token = {type="badUrl"}
return token, ptr
end
end
local cps = {}
while true do
if ptr > #s or substrCompareAsciiChar(s, ptr, ")") then
local token = {type="url"}
token.value = makeString(cps)
token.quoteCharacter = ""
return token, ptr+1
elseif substrCompareAsciiChar(s, ptr, " \t\n") then
from, to = matchWs(s, ptr+1)
ptr = to+1
if ptr > #s or substrCompareAsciiChar(s, ptr, ")") then
local token = {type="url"}
token.value = makeString(cps)
token.quoteCharacter = ""
return token, ptr+1
else
ptr = consumeRemnantsOfBadUrl(s, ptr)
local token = {type="badUrl"}
return token, ptr
end
elseif substrCompareAsciiChar(s, ptr, "\"'(") or matchNonPrintable(s, ptr) then
print("[css] Parse error: Invalid character at position "..ptr..".")
ptr = consumeRemnantsOfBadUrl(s, ptr)
local token = {type="badUrl"}
return token, ptr
elseif substrCompareAsciiChar(s, ptr, "\\") then
if isEscapeStart(s, ptr) then
local cp
cp, ptr = consumeEscape(s, ptr+1)
table.insert(cps, cp)
else
print("[css] Parse error: Invalid escape at position "..ptr..".")
ptr = consumeRemnantsOfBadUrl(s, ptr)
local token = {type="badUrl"}
return token, ptr
end
else
local cp = utf8.codepoint(s, 1, 1, ptr)
table.insert(cps, cp)
ptr = ptr+utf8.charlen(s, ptr)
end
end
end
function consumeUnicodeRangeToken(s, ptr)
-- Assume the initial "U+" has been consumed, and we're at a hex or "?".
local from, to, hex = s:find(
"^([%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?)", ptr
)
local digitCount = to-from+1
ptr = to+1
from, to = s:find("^"..("%??"):rep(6-digitCount), ptr)
local questionMarkCount = to-from+1
ptr = to+1
local token = {type="unicodeRange"}
if questionMarkCount > 0 then
token.from = tonumber(hex..("0"):rep(questionMarkCount), 16)
token.to = tonumber(hex..("F"):rep(questionMarkCount), 16)
return token, ptr
end
token.from = tonumber(hex, 16)
if s:find("^%-[%dA-Fa-f]", ptr) then
ptr = ptr+1
local hexRangeTo
from, to, hexRangeTo = s:find(
"^([%dA-Fa-f][%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?)", ptr
)
ptr = to+1
token.to = tonumber(hexRangeTo, 16)
else
token.to = token.from
end
return token, ptr
end
function consumeEscape(s, ptr)
-- Assume "\" has been consumed and we're not at a newline.
if ptr > #s then
return CP_REPLACE, ptr
end
if s:find("^[%dA-Fa-f]", ptr) then
local hex = s:match(
"^[%dA-Fa-f][%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?[%dA-Fa-f]?", ptr
)
ptr = ptr+#hex
if substrCompareAsciiChar(s, ptr, " \t\n") then
ptr = ptr+1
end
local cp = tonumber(hex, 16)
if cp == CP_NULL or isSurrogateCodepoint(cp) or not isValidCodepoint(cp) then
return CP_REPLACE, ptr
else
return cp, ptr
end
end
local cp = utf8.codepoint(s, 1, 1, ptr)
ptr = ptr+utf8.charlen(s, ptr)
return cp, ptr
end
function consumeName(s, ptr)
-- Note: No verification is being done.
local cps = {}
while true do
if isName(s, ptr) then
local cp = utf8.codepoint(s, 1, 1, ptr)
table.insert(cps, cp)
ptr = ptr+utf8.charlen(s, ptr)
elseif isEscapeStart(s, ptr) then
local cp
cp, ptr = consumeEscape(s, ptr+1)
table.insert(cps, cp)
else
return makeString(cps), ptr
end
end
end
function consumeNumber(s, ptr)
-- Note: No verification is being done.
local nRepr = {}
local nType = "integer"
local part = s:match("^[-+]?%d*", ptr) -- May be an empty string.
table.insert(nRepr, part)
ptr = ptr+#part
if s:find("^%.%d", ptr) then
part = s:match("^%.%d+", ptr)
table.insert(nRepr, part)
ptr = ptr+#part
nType = "number"
end
if s:find("^[Ee][-+]?%d", ptr) then
part = s:match("^[Ee][-+]?%d+", ptr)
table.insert(nRepr, part)
ptr = ptr+#part
nType = "number"
end
nRepr = table.concat(nRepr)
-- This probably works most of the time. Probably... @Incomplete
local n = tonumber(nRepr)
assert(n, nRepr)
return nRepr, n, nType, ptr
end
function consumeRemnantsOfBadUrl(s, ptr)
while true do
if ptr > #s or substrCompareAsciiChar(s, ptr, ")") then
return ptr+1
elseif isEscapeStart(s, ptr) then
local cp
cp, ptr = consumeEscape(s, ptr)
-- Throw away the codepoint.
else
ptr = ptr+utf8.charlen(s, ptr)
end
end
end
function consumeWhitespace(s, ptr)
local ws = s:match("^[ \t\n]+", ptr)
ptr = ptr+#ws
local token = {type="whitespace"}
token.value = ws
return token, ptr
end
function consumeComment(s, ptr)
-- Assume the initial "/*" has been consumed.
local comment
local from, to = s:find("*/", ptr, true)
if from then
comment = s:sub(ptr, to-2)
ptr = to+1
else
comment = s:sub(ptr)
ptr = #s+1
end
token = newTokenComment(comment)
return token, ptr
end
function css.tokenize(s)
-- Preprocess stream. https://www.w3.org/TR/css-syntax-3/#input-preprocessing
s = s
:gsub("\r\n?", "\n")
:gsub("\f", "\n")
:gsub("%z", CHAR_REPLACE)
-- Tokenize.
-- https://www.w3.org/TR/css-syntax-3/#tokenization
--
-- <ident-token>
-- <function-token>
-- <at-keyword-token>
-- <hash-token>
-- <string-token>, <bad-string-token>
-- <url-token>, <bad-url-token>
-- <delim-token>
-- <number-token>
-- <percentage-token>
-- <dimension-token>
-- <unicode-range-token>
-- <include-match-token>
-- <dash-match-token>
-- <prefix-match-token>
-- <suffix-match-token>
-- <substring-match-token>
-- <column-token>
-- <whitespace-token>
-- <CDO-token>, <CDC-token>
-- <colon-token>
-- <semicolon-token>
-- <comma-token>
-- <[-token>, <]-token>
-- <(-token>, <)-token>
-- <{-token>, <}-token>
--
-- <ident-token>, <function-token>, <at-keyword-token>, <hash-token>, <string-token>, <url-token>: value = 0+ cps.
-- <delim-token>: value = 1 cp.
-- <number-token>, <percentage-token>, <dimension-token>: representation = one+ cps, value = numeric.
-- <dimension-token>: additional unit = 1+ cps.
-- <unicode-range-token>: start and end = 2 integers.
local tokens = {}
local ptr = 1
local ptrLast = 1
while ptr <= #s do
local c1 = s:sub(ptr, ptr ) -- We probably don't need to use utf8.sub() here.
local c2 = s:sub(ptr+1, ptr+1)
local c3 = s:sub(ptr+2, ptr+2)
local c4 = s:sub(ptr+3, ptr+3)
local token
--------------------------------
if c1 == " " or c1 == "\t" or c1 == "\n" then
token, ptr = consumeWhitespace(s, ptr)
--------------------------------
elseif c1 == '"' or c1 == "'" then
token, ptr = consumeStringToken(s, ptr+1, c1)
--------------------------------
elseif c1 == "#" then
if isName(s, ptr+1) or isEscapeStart(s, ptr+1) then
token = {type="hash"}
token.idType = isIdentStart(s, ptr+1) and "id" or "unrestricted"
token.value, ptr = consumeName(s, ptr+1)
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "$" then
if c2 == "=" then
token, ptr = {type="suffixMatch"}, ptr+2
else
token = {type="delim", value=c1}
end
elseif c1 == "*" then
if c2 == "=" then
token, ptr = {type="substringMatch"}, ptr+2
else
token = {type="delim", value=c1}
end
elseif c1 == "^" then
if c2 == "=" then
token, ptr = {type="prefixMatch"}, ptr+2
else
token = {type="delim", value=c1}
end
elseif c1 == "|" then
if c2 == "=" then
token, ptr = {type="dashMatch"}, ptr+2
elseif c2 == "|" then
token, ptr = {type="columnMatch"}, ptr+2
else
token = {type="delim", value=c1}
end
elseif c1 == "~" then
if c2 == "=" then
token, ptr = {type="includeMatch"}, ptr+2
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "(" then
token = {type="("}
elseif c1 == ")" then
token = {type=")"}
elseif c1 == "," then
token = {type="comma"}
elseif c1 == ":" then
token = {type="colon"}
elseif c1 == ";" then
token = {type="semicolon"}
elseif c1 == "[" then
token = {type="["}
elseif c1 == "]" then
token = {type="]"}
elseif c1 == "{" then
token = {type="{"}
elseif c1 == "}" then
token = {type="}"}
--------------------------------
elseif c1 == "+" then
if isNumberStart(s, ptr+1) then
token, ptr = consumeNumericToken(s, ptr)
else
token = {type="delim", value=c1}
end
elseif c1 == "-" then
if isNumberStart(s, ptr+1) then
token, ptr = consumeNumericToken(s, ptr)
elseif isIdentStart(s, ptr+1) then
token, ptr = consumeIdentLikeToken(s, ptr)
elseif c2 == "-" and c3 == ">" then
token, ptr = {type="cdc"}, ptr+3
else
token = {type="delim", value=c1}
end
elseif c1 == "." then
if isNumberStart(s, ptr+1) then
token, ptr = consumeNumericToken(s, ptr)
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "/" then
if c2 == "*" then
token, ptr = consumeComment(s, ptr+2)
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "<" then
if c2 == "!" and c3 == "-" and c4 == "-" then
token, ptr = {type="cdo"}, ptr+4
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "@" then
if isIdentStart(s, ptr+1) then
token = {type="atKeyword"}
token.value, ptr = consumeName(s, ptr+1)
else
token = {type="delim", value=c1}
end
--------------------------------
elseif c1 == "\\" then
if isEscapeStart(s, ptr) then
token, ptr = consumeIdentLikeToken(s, ptr)
else
print("[css] Parse error: Invalid escape at position "..ptr..".")
token = {type="delim", value=c1}
end
--------------------------------
elseif substrCompareAsciiChar(c1, 1, "0123456789") then
token, ptr = consumeNumericToken(s, ptr)
--------------------------------
elseif c1 == "U" or c1 == "u" then
if c2 == "+" and substrCompareAsciiChar(c3, 1, "0123456789ABCDEFabcdef?") then
token, ptr = consumeUnicodeRangeToken(s, ptr+2) -- Note the consumption.
else
token, ptr = consumeIdentLikeToken(s, ptr)
end
--------------------------------
elseif isNameStart(s, ptr) then
token, ptr = consumeIdentLikeToken(s, ptr)
--------------------------------
else
token = {type="delim", value=c1}
end
--------------------------------
assert(token)
table.insert(tokens, token)
if ptr == ptrLast then ptr = ptr+#c1 end
ptrLast = ptr
end
return tokens
end
--==============================================================
--= Serializer =================================================
--==============================================================
local canTrimBeforeNextToken
local formatNumberFromToken
function formatNumberFromToken(token)
local n = token.value
local repr = token.representation:gsub("^%+", "")
local nStr = F("%.10g", n)
if #nStr > #repr or tonumber(nStr) ~= n then nStr = repr end
nStr = nStr:gsub("0%.", ".")
return nStr
end
function canTrimBeforeNextToken(tokens, i)
local token = tokens[i+1]
if not token then return true end
return not isAny(token.type, "ident","function","url","badUrl","number","percentage","dimension","unicodeRange")
end
function css.serializeAndMinimize(tokens, options)
options = options or {}
return css.serialize(css.minimize(tokens, options), options)
end
function css.serialize(tokens, options)
options = options or {}
local out = {}
local function write(v)
table.insert(out, v)
end
-- https://drafts.csswg.org/cssom/#serialize-an-identifier
local function writeName(v, unrestricted, trimTrailingSpace)
local cps = {}
local firstCp = nil
for cp, from, to, charPos in utf8.codes(v) do
firstCp = firstCp or cp
if cp == CP_NULL then
table.insert(cps, CP_REPLACE)
elseif
isControlCharacterCodepoint(cp)
or cp == CP_DELETE
or (
(
charPos == 1 and not unrestricted
or charPos == 2 and firstCp == CP_DASH
)
and inRange(cp, CP_0, CP_9)
)
then
local escape = F("\\%X ", cp)
for i = 1, #escape do
table.insert(cps, escape:byte(i))
end
elseif charPos == 1 and cp == CP_DASH and #v == 1 then
table.insert(cps, CP_BACKSLASH)
table.insert(cps, cp)
elseif
cp >= CP_NONASCII_START
or cp == CP_DASH
or cp == CP_UNDERSCORE
or inRange(cp, CP_0, CP_9)
or inRange(cp, CP_A, CP_Z)
or inRange(cp, CP_a, CP_z)
then
table.insert(cps, cp)
else
table.insert(cps, CP_BACKSLASH)
table.insert(cps, cp)
end
end
if trimTrailingSpace and cps[#cps] == 32 then
table.remove(cps)
end
write(makeString(cps))
end
-- https://drafts.csswg.org/cssom/#serialize-a-string
function writeString(v, quoteChar)
if not quoteChar then
-- http://tantek.com/CSS/Examples/boxmodelhack.html#content
local ie5ParsingBugExploitQuoteChar = v:match"^([\"']).+[\"']$"
local hasDouble = v:find('"', 1, true) ~= nil
local hasSingle = v:find("'", 1, true) ~= nil
quoteChar = ie5ParsingBugExploitQuoteChar or hasDouble and not hasSingle and "'" or '"'
end
v = v
:gsub("%z", CHAR_REPLACE)
:gsub("["..quoteChar.."\\]", "\\%0")
:gsub("[\1-\31]", function(c)
return F("\\%X ", c:byte())
end)
write(quoteChar)
write(v)
write(quoteChar)
end
function writePlainUrlValue(v)
v = v
:gsub("%z", CHAR_REPLACE)
:gsub("[\\ ()\"']", "\\%0")
:gsub("[\1-\31]", function(c)
return F("\\%X ", c:byte())
end)
write(v)
end
for i, token in ipairs(tokens) do
if token.type == "dimension" then
local nRepr = formatNumberFromToken(token)
write(nRepr)
-- Eliminate ambiguity with scientific notation.
if not nRepr:find("n", 2, true) and token.unit:find"^[Ee][-+]?%d" then
write("e0") -- W3C CSS validator still complains...
end
writeName(token.unit, false, canTrimBeforeNextToken(tokens, i))
elseif token.type == "percentage" then
write(formatNumberFromToken(token))
write("%")
elseif token.type == "number" then
write(formatNumberFromToken(token))
elseif token.type == "function" then
writeName(token.value, false, true)
write("(")
elseif token.type == "ident" then
writeName(token.value, false, canTrimBeforeNextToken(tokens, i))
elseif token.type == "string" then
writeString(token.value, (options.preserveQuotes and token.quoteCharacter or nil))
elseif token.type == "badString" then
if options.strict then
error("[css] BAD_STRING token at position "..i..".")
else
print("[css] Warning: BAD_STRING token at position "..i..".")
write('""')
end
elseif token.type == "url" then
local v = token.value
write("url(")
if options.preserveQuotes then
if token.quoteCharacter ~= "" then
writeString(v, token.quoteCharacter)
elseif v ~= "" then
writePlainUrlValue(v)
end
elseif v == "" then
-- void
elseif v:find"[ ()\"']" then
-- https://drafts.csswg.org/cssom/#serialize-a-url
writeString(v)
else
-- Custom serialization code. Hopefully works in all cases.
-- Otherwise, we may have to revert to using writeString().
writePlainUrlValue(v)
end
write(")")
elseif token.type == "badUrl" then
if options.strict then
error("[css] BAD_URL token at position "..i..".")
else
print("[css] Warning: BAD_URL token at position "..i..".")
write("url()")
end
elseif token.type == "unicodeRange" then
local from = F("%X", token.from)
local to = F("%X", token.to)
local preFrom = from :gsub("0+$", "")
local preTo = to :gsub("F+$", "")
write("U+")
if from == to then
write(from)
-- U+12300-123FF => 123?? -- ok
-- U+12390-123FF => 123/? -- fail
-- U+01230-123FF => ////? -- fail
elseif #from == #to and preFrom == preTo then
write(preFrom)
write(("?"):rep(#from-#preFrom))
else
write(from)
write("-")
write(to)
end
elseif token.type == "whitespace" then
write(token.value)
elseif token.type == "comment" then
assert(not token.value:find"%*/")
write("/*")
write(token.value)
write("*/")
elseif token.type == "hash" then
write("#")
writeName(token.value, (token.idType == "unrestricted"), canTrimBeforeNextToken(tokens, i))
elseif token.type == "suffixMatch" then
write("$=")
elseif token.type == "substringMatch" then
write("*=")
elseif token.type == "prefixMatch" then
write("^=")
elseif token.type == "dashMatch" then
write("|=")
elseif token.type == "includeMatch" then
write("~=")
elseif token.type == "columnMatch" then
write("||")
elseif token.type == "comma" then
write(",")
elseif token.type == "colon" then
write(":")
elseif token.type == "semicolon" then
write(";")
elseif token.type == "cdo" then
write("<!--")
elseif token.type == "cdc" then
write("-->")
elseif token.type == "atKeyword" then
write("@")
writeName(token.value, false, canTrimBeforeNextToken(tokens, i))
elseif token.type == "(" or token.type == ")" then
write(token.type)
elseif token.type == "[" or token.type == "]" then
write(token.type)
elseif token.type == "{" or token.type == "}" then
write(token.type)
elseif token.type == "delim" then
write(token.value)
if token.value == "\\" then write("\n") end
else
error("[css][internal] Unknown token type '"..tostring(token.type).."'.")
end
end
return table.concat(out)
end
--==============================================================
--= Minimizer ==================================================
--==============================================================
local getNextToken, getNextNonWsToken, getNextNonWsOrSemicolonToken
local isSucceededBy
local mustSeparateTokens
function mustSeparateTokens(a, b, isInRule)
local at, av = a.type, a.value
local bt, bv = b.type, b.value
return
at == "ident" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange" or
bt == "cdc" or
bt == "(" or
not isInRule and ( -- :SpacingFix
bt == "hash" or
bt == "colon" or
bt == "delim" and bv == "."
)
)
or at == "atKeyword" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange" or
bt == "cdc"
)
or at == "hash" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange" or
bt == "cdc" or
bt == "(" or
not isInRule and ( -- :SpacingFix
bt == "hash" or
bt == "colon" or
bt == "delim" and bv == "."
)
)
or at == "dimension" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange" or
bt == "cdc" or
bt == "("
)
or at == "delim" and av == "#" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange"
)
-- or at == "delim" and av == "-" and ( -- :W3cVal
-- bt == "ident" or
-- bt == "function" or
-- bt == "url" or
-- bt == "badUrl" or
-- bt == "number" or
-- bt == "percentage" or
-- bt == "dimension" or
-- bt == "unicodeRange"
-- )
or at == "number" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "unicodeRange"
)
or at == "delim" and av == "@" and (
bt == "ident" or
bt == "function" or
bt == "url" or
bt == "badUrl" or
-- bt == "delim" and bv == "-" or -- :W3cVal
bt == "unicodeRange"
)
or at == "unicodeRange" and (
bt == "ident" or
bt == "function" or
bt == "number" or
bt == "percentage" or
bt == "dimension" or
bt == "delim" and bv == "?"
)
or at == "delim" and av == "." and (
bt == "number" or
bt == "percentage" or
bt == "dimension"
)
-- or at == "delim" and av == "+" and ( -- :W3cVal
-- bt == "number" or
-- bt == "percentage" or
-- bt == "dimension"
-- )
or not isInRule and ( -- :SpacingFix
at == "]" and (
bt == "ident"
)
)
or at == "delim" and bt == "delim" and (
av == "$" and bv == "=" or
av == "*" and bv == "=" or
av == "^" and bv == "=" or
av == "~" and bv == "=" or
av == "|" and bv == "=" or
av == "|" and bv == "|" or
av == "/" and bv == "*"
)
-- Silence the W3C CSS validator. :W3cVal
or at == "delim" and (av == "+" or av == "-")
or bt == "delim" and (bv == "+" or bv == "-")
end
function getNextToken(tokens, i, dir)
for i = i, (dir < 0 and 1 or #tokens), dir do
local token = tokens[i]
if token.type ~= "comment" then
return token, i
end
end
return nil
end
function getNextNonWsToken(tokens, i, dir)
for i = i, (dir < 0 and 1 or #tokens), dir do
local token = tokens[i]
if token.type ~= "comment" and token.type ~= "whitespace" then
return token, i
end
end
return nil
end
function getNextNonWsOrSemicolonToken(tokens, i, dir)
for i = i, (dir < 0 and 1 or #tokens), dir do
local token = tokens[i]
if token.type ~= "comment" and token.type ~= "whitespace" and token.type ~= "semicolon" then
return token, i
end
end
return nil
end
-- bool = isSucceededBy( tokens, startIndex, direction, matchSequence... )
-- Match sequences:
-- * [ doNotMatch=="!" ], tokenTypeLike
-- * [ doNotMatch=="!" ], tokenTypeLike=="atKeyword", tokenValue
-- * [ doNotMatch=="!" ], tokenTypeLike=="delim", tokenValue
-- * [ doNotMatch=="!" ], tokenTypeLike=="ident", tokenValue
-- tokenTypeLike = tokenType|"numberLike"|"integer"
function isSucceededBy(tokens, tokIndex, dir, ...)
local argCount = select("#", ...)
local argIndex = 1
-- print("~~~~~~~~~~~~~~~~~~~~~~~~")
-- print("isSucceededBy", argCount, "|", ...)
while argIndex <= argCount do
local token = tokens[tokIndex]
if not token then return false end
-- print("arg "..argIndex)
if token.type ~= "comment" then
local tokType = select(argIndex, ...)
argIndex = argIndex+1
local wantMatch = true
if tokType == "!" then
wantMatch = false
tokType = select(argIndex, ...)
argIndex = argIndex+1
end
-- print(wantMatch and "want:typ " or "nowant:typ", tokType)
-- print("got:typ", token.type)
if tokType == "integer" then
if (token.type == "number" and token.numberType == "integer") ~= wantMatch then
-- print("nope")
return false
end
elseif tokType == "numberLike" then
if isAny(token.type, "dimension","percentage","number") ~= wantMatch then
-- print("nope")
return false
end
else
if (token.type == tokType) ~= wantMatch then
-- print("nope")
return false
end
end
if isAny(tokType, "ident","delim","atKeyword") then
-- print(wantMatch and "want:val " or "nowant:val", select(argIndex, ...))
-- print("got:val", token.value)
if (token.value == select(argIndex, ...)) ~= wantMatch then
-- print("nope")
return false
end
argIndex = argIndex+1
end
end
tokIndex = tokIndex+dir
end
-- print("YYEEESSS")
return true
end
-- css = minimize( css [, options ] )
-- tokens = minimize( tokens [, options ] )
function css.minimize(tokensIn, options)
-- @Incomplete:
-- * No empty rules: "body div{}" => ""
-- * Unstring font names, if possible: '"Arial"' => 'Arial'
-- * Omit space after escape sometimes: "4px\9 }" => "4px\9}"
-- * Maybe preserve space: "src:url()format()" => "src:url() format()"
-- * Maybe don't replace NUL bytes: "�" => "\0 "
-- * Do magical things with -ms-filter props. Ugh...
if type(tokensIn) == "string" then
return css.serializeAndMinimize(css.tokenize(tokensIn), options)
end
local scopeStack
local currentProperty
local currentAtKeyword
local colonsAfterProp
local nextTokenIndex
local function enter(scope)
assert(scope.name)
assert(scope.exit)
table.insert(scopeStack, scope)
end
local function exit(symbol, i)
local scope = table.remove(scopeStack)
if scope.exit ~= symbol then
error(F(
"[css] Unbalanced scopes at position %d. (expected to exit '%s' scope with '%s', but got '%s')",
i, scope.name, tostring(scope.exit), symbol
), 2)
end
end
local function isAt(scopeName)
return scopeStack[#scopeStack].name == scopeName
end
local function isInside(scopeName)
for _, scope in ipairs(scopeStack) do
if scope.name == scopeName then return true end
end
return false
end
-- eachToken( tokens, startIndex=auto, endIndex=auto, direction=1, callback )
-- direction = 1|-1
-- [ token = ] callback( token, tokenType, index )
-- Note: currentProperty etc. is only available if iterating forwards from index 1.
local function eachToken(tokens, iStart, iEnd, dir, cb)
scopeStack = {{name="file"}}
currentProperty = nil
currentAtKeyword = nil
colonsAfterProp = 0
nextTokenIndex = 0
dir = dir or 1
iStart = iStart or (dir < 0 and #tokens or 1)
iEnd = iEnd or (dir < 0 and 1 or #tokens)
local iMin = math.min(iStart, iEnd)
local iMax = math.max(iStart, iEnd)
local i = iStart-dir
local doExtra = (dir == 1 and iStart == 1)
while true do
if nextTokenIndex > 0 then
i = nextTokenIndex
nextTokenIndex = 0
doExtra = false
else
i = i+dir
end
local token = tokens[i]
if not token or i < iMin or i > iMax then break end
local tokType = token.type
if not doExtra then
cb(token, tokType, i)
elseif tokType == "function" then
cb(token, tokType, i)
enter{ name="function", exit=")" }
elseif tokType == "ident" then
token = cb(token, tokType, i) or token
if isAt"rule" and not currentProperty then
currentProperty = token.value
end
elseif tokType == "colon" then
cb(token, tokType, i)
if currentProperty and isAt"rule" then
colonsAfterProp = colonsAfterProp+1
end
elseif tokType == "semicolon" then
cb(token, tokType, i)
if isAt"rule" then
currentProperty = nil
colonsAfterProp = 0
end
currentAtKeyword = nil -- Possible end of @charset ""; or similar.
elseif tokType == "atKeyword" then
token = cb(token, tokType, i) or token
currentAtKeyword = token.value
elseif tokType == "(" then
cb(token, tokType, i)
enter{ name="(", exit=")" }
elseif tokType == ")" then
cb(token, tokType, i)
exit(")", i)
elseif tokType == "[" then
cb(token, tokType, i)
enter{ name="[", exit="]" }
elseif tokType == "]" then
cb(token, tokType, i)
exit("]", i)
elseif tokType == "{" then
cb(token, tokType, i)
if not currentAtKeyword then
enter{ name="rule", exit="}" }
-- Note: @document is experimental and Firefox-only as of 2018-07-18.
elseif isAny(currentAtKeyword, "media","supports","document") then
enter{ name="condGroup", exit="}" }
elseif isAny(currentAtKeyword, "font-face","page") then
enter{ name="rule", exit="}" }
else
enter{ name="@"..currentAtKeyword, exit="}" }
end
currentAtKeyword = nil
elseif tokType == "}" then
if isAt"rule" then
currentProperty = nil
colonsAfterProp = 0
end
cb(token, tokType, i)
exit("}", i)
else
cb(token, tokType, i)
end
assert(#scopeStack >= 1)
end
-- assert(#scopeStack == 1) -- DEBUG: EOF is allowed to appear inside a scope.
end
local function printPeek(tokens, i, count)
print("----------------")
for j = math.min(i+count, i), math.max(i+count, i) do
if not tokens[j] then break end
print(j-i, tokens[j].type, tokens[j].value or "")
end
print("----------------")
end
-- Create minimized token array.
--------------------------------
local tokenSourceSet = {}
local tokensOut = {}
local keepNextComment = false
local function add(token)
if tokenSourceSet[token] then
local tokSource = token
token = {}
for k, v in pairs(tokSource) do
token[k] = v
end
end
table.insert(tokensOut, token)
return token
end
eachToken(tokensIn, nil, nil, nil, function(tokIn, tokType, i)
tokenSourceSet[tokIn] = true
if isAny(tokType, "dimension","percentage") then
if
options.autoZero ~= false
and tokIn.value == 0
and not isAny(currentProperty, "flex","flex-basis")
and not (isInside"function" or isInside"(" or isInside"@keyframes")
then
add(newTokenNumber(0))
else
add(tokIn)
end
elseif tokType == "number" then
add(tokIn)
elseif tokType == "function" then
local tokOut = add(tokIn)
-- Lower-case function names, except for crazy things like filter:progid:DXImageTransform.Microsoft.matrix().
if colonsAfterProp == 1 or isAt"file" or isAt"@media" or isAt"@supports" or isAt"@document" then
tokOut.value = tokOut.value:lower()
-- Fix letter case for rotateX etc.
if
substrCompareAsciiChar(tokOut.value, #tokOut.value, "xyz")
and isAny(tokOut.value:sub(1, #tokOut.value-1), "rotate","scale","skew","translate")
then
tokOut.value = tokOut.value:gsub(".$", string.upper)
end
end
return tokOut
elseif tokType == "ident" then
local tokPrev = getNextToken(tokensOut, #tokensOut, -1)
local tokNext = getNextNonWsToken(tokensIn, i+1, 1)
if isAt"rule" and not currentProperty then
local tokOut = add(tokIn)
tokOut.value = tokOut.value:lower()
return tokOut
elseif currentAtKeyword == "media" then
-- Is this ok or must we check for specific keywords, like "screen" etc.?
local tokOut = add(tokIn)
tokOut.value = tokOut.value:lower()
return tokOut
elseif tokPrev and tokPrev.type == "colon" and not isAt"rule" then
-- Both ':' and '::'.
local tokOut = add(tokIn)
tokOut.value = tokOut.value:lower()
return tokOut
elseif
currentProperty
and #tokIn.value == 4 and tokIn.value:lower() == "none"
and isAny(currentProperty, "background","border","border-top","border-right","border-bottom","border-left")
and (not tokNext or tokNext.type == "semicolon" or tokNext.type == "}")
then
add(newTokenNumber(0))
else
add(tokIn)
end
elseif tokType == "string" then
add(tokIn)
elseif tokType == "badString" then
if options.strict then
error("[css] BAD_STRING token at position "..i..".")
else
print("[css] Warning: BAD_STRING token at position "..i..".")
add(tokIn)
end
elseif tokType == "url" then
add(tokIn)
elseif tokType == "badUrl" then
if options.strict then
error("[css] BAD_URL token at position "..i..".")
else
print("[css] Warning: BAD_URL token at position "..i..".")
add(tokIn)
end
elseif tokType == "whitespace" then
-- Note: There shouldn't ever be two whitespace tokens after
-- each other (I think), but there could be two or more
-- whitespace tokens with comments in-between.
local tokPrev = getNextToken(tokensOut, #tokensOut, -1)
local tokNext = getNextNonWsToken(tokensIn, i+1, 1)
if
tokPrev and tokNext and (
(
mustSeparateTokens(tokPrev, tokNext, isInside"rule")
or tokensOut[#tokensOut].type == "number" and (
tokNext.type == "dimension"
or tokNext.type == "percentage"
or tokNext.type == "number"
)
)
and not (
tokensOut[#tokensOut].type == "comment"
and tokensIn[i+1].type == "comment"
and tokensIn[i+1].value:find"^!"
)
)
then
add(newTokenWhitespace(" "))
end
elseif tokType == "comment" then
local tokPrev = getNextToken(tokensOut, #tokensOut, -1) -- Could be whitespace.
-- Important comment.
if substrCompareAsciiChar(tokIn.value, 1, "!") then
add(tokIn)
-- Child selector hack for IE7 and below.
-- html >/**/ body p {
elseif tokPrev and tokPrev.type == "delim" and tokPrev.value == ">" then
add(newTokenComment())
-- Comment parsing hack for IE Mac.
-- /*\*/ hidden /**/
elseif tokIn.value:find"\\$" then
add(newTokenComment("\\"))
keepNextComment = true
elseif keepNextComment then
add(newTokenComment())
end
elseif tokType == "hash" then
if currentProperty and isAt"rule" then
local tokOut = add(tokIn)
tokOut.value = tokOut.value:lower()
-- Note: It seems CSS4 will add #RRGGBBAA and #RGBA formats, so this code will probably have to be updated.
if not isAny(#tokOut.value, 3,6) then
print("[css] Warning: Color value looks incorrect: #"..tokOut.value)
end
return tokOut
else
add(tokIn)
end
elseif tokType == "semicolon" then
local tokPrev = getNextNonWsOrSemicolonToken(tokensOut, #tokensOut, -1)
local tokNext = getNextNonWsToken(tokensIn, i+1, 1)
if
tokNext and not isAny(tokNext.type, "}","semicolon")
and not (tokPrev and isAny(tokPrev.type, "{","}"))
then
add(tokIn)
end
elseif tokType == "atKeyword" then
local tokOut = add(tokIn)
tokOut.value = tokOut.value:lower()
return tokOut
elseif tokType == "unicodeRange" then
add(tokIn)
elseif tokType == "suffixMatch" then
add(tokIn)
elseif tokType == "substringMatch" then
add(tokIn)
elseif tokType == "prefixMatch" then
add(tokIn)
elseif tokType == "dashMatch" then
add(tokIn)
elseif tokType == "includeMatch" then
add(tokIn)
elseif tokType == "columnMatch" then
add(tokIn)
elseif tokType == "comma" then
add(tokIn)
elseif tokType == "colon" then
add(tokIn)
elseif tokType == "cdo" then
add(tokIn)
elseif tokType == "cdc" then
add(tokIn)
elseif tokType == "(" then
add(tokIn)
elseif tokType == ")" then
add(tokIn)
elseif tokType == "[" then
add(tokIn)
elseif tokType == "]" then
add(tokIn)
elseif tokType == "{" then
add(tokIn)
elseif tokType == "}" then
add(tokIn)
elseif tokType == "delim" then
add(tokIn)
else
error("[css][internal] Unknown token type '"..tostring(tokType).."'.")
end
end)
-- Remove empty rules.
--------------------------------
local ruleBeginnings = {}
local ruleDepth = 0
local lastRuleStart = 0
local isInSomethingInFileScope = false
tokensIn = tokensOut
tokensOut = {}
eachToken(tokensIn, nil, nil, nil, function(tokIn, tokType, i)
add(tokIn)
if not isInSomethingInFileScope and tokType ~= "comment" then
lastRuleStart = #tokensOut
isInSomethingInFileScope = true
elseif tokType == "{" then
table.insert(ruleBeginnings, lastRuleStart)
ruleDepth = ruleDepth+1
lastRuleStart = #tokensOut+1
elseif tokType == "}" then
local ruleStart = table.remove(ruleBeginnings)
ruleDepth = ruleDepth-1
if not ruleStart then
error("[css] Uneven curly brackets.")
end
local tokPrev = getNextToken(tokensOut, #tokensOut-1, -1)
if tokPrev.type == "{" then
for j = #tokensOut, ruleStart, -1 do
table.remove(tokensOut, j)
end
end
lastRuleStart = #tokensOut+1
if ruleDepth == 0 then
isInSomethingInFileScope = false
end
elseif tokType == "semicolon" and currentAtKeyword then
lastRuleStart = #tokensOut+1
if ruleDepth == 0 then
isInSomethingInFileScope = false
end
end
end)
if tokensOut[1] and tokensOut[#tokensOut].type == "semicolon" then
table.remove(tokensOut)
end
-- Minimize specific properties.
--------------------------------
-- Replace/remove.
eachToken(tokensOut, nil, nil, -1, function(token, tokType, i)
-- rgba(*,*,*,1) -> rgb(*,*,*)
-- hsla(*,*,*,1) -> hsl(*,*,*)
if
tokType == "function"
and isAny(token.value, "hsla","rgba")
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "numberLike",
--[[2]] "comma",
--[[3]] "numberLike",
--[[4]] "comma",
--[[5]] "numberLike",
--[[6]] "comma",
--[[7]] "numberLike",
--[[8]] ")"
)
and tokensOut[i+7].value == 1
then
token.value = token.value:sub(1, 3)
table.remove(tokensOut, i+7)
table.remove(tokensOut, i+6)
nextTokenIndex = i
return
end
-- rgb(*,*,*) -> #******
if
tokType == "function"
and token.value == "rgb"
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "integer",
--[[2]] "comma",
--[[3]] "integer",
--[[4]] "comma",
--[[5]] "integer",
--[[6]] ")"
)
then
token = {type="hash"}
token.value = F(
"%02x%02x%02x",
clamp(tokensOut[i+1].value, 0, 255),
clamp(tokensOut[i+3].value, 0, 255),
clamp(tokensOut[i+5].value, 0, 255)
)
token.idType = isIdentStart(token.value, 1) and "id" or "unrestricted"
for j = i+6, i+1, -1 do
table.remove(tokensOut, j)
end
tokensOut[i] = token
-- Make sure we don't have an ID or something right after.
if tokensOut[i+1] and mustSeparateTokens(token, tokensOut[i+1], true) then
table.insert(tokensOut, i+1, newTokenWhitespace(" "))
end
-- We also don't need any space before anymore.
if tokensOut[i-1] and tokensOut[i-1].type == "whitespace" then
table.remove(tokensOut, i-1)
nextTokenIndex = i-1
else
nextTokenIndex = i
end
return
end
-- background-position:0 0 0 0 -> background-position:0 0
if
tokType == "ident"
and token.value == "background-position"
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "colon",
--[[2]] "numberLike",
--[[3]] "whitespace",
--[[4]] "numberLike",
--[[5]] "whitespace",
--[[6]] "numberLike",
--[[7]] "whitespace",
--[[8]] "numberLike"
)
and tokensOut[i+2].value == 0
and tokensOut[i+4].value == 0
and tokensOut[i+6].value == 0
and tokensOut[i+8].value == 0
then
for j = i+8, i+5, -1 do
table.remove(tokensOut, j)
end
nextTokenIndex = i
return
end
-- margin:1 2 1 2 -> margin:1 2
-- padding:1 2 1 2 -> padding:1 2
if
tokType == "ident"
and isAny(token.value, "margin","padding","background-position")
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "colon",
--[[2]] "numberLike",
--[[3]] "whitespace",
--[[4]] "numberLike",
--[[5]] "whitespace",
--[[6]] "numberLike",
--[[7]] "whitespace",
--[[8]] "numberLike"
)
and tokensOut[i+2].type == tokensOut[i+6].type
and tokensOut[i+4].type == tokensOut[i+8].type
and tokensOut[i+2].value == tokensOut[i+6].value
and tokensOut[i+4].value == tokensOut[i+8].value
then
for j = i+8, i+5, -1 do
table.remove(tokensOut, j)
end
nextTokenIndex = i
return
end
-- margin:1 2 3 2 -> margin:1 2 3
-- padding:1 2 3 2 -> padding:1 2 3
if
tokType == "ident"
and isAny(token.value, "margin","padding")
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "colon",
--[[2]] "numberLike",
--[[3]] "whitespace",
--[[4]] "numberLike",
--[[5]] "whitespace",
--[[6]] "numberLike",
--[[7]] "whitespace",
--[[8]] "numberLike"
)
and tokensOut[i+4].type == tokensOut[i+8].type
and tokensOut[i+4].value == tokensOut[i+8].value
then
for j = i+8, i+7, -1 do
table.remove(tokensOut, j)
end
nextTokenIndex = i
return
end
-- margin:0 0 -> margin:0
-- padding:0 0 -> padding:0
if
tokType == "ident"
and isAny(token.value, "margin","padding")
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "colon",
--[[2]] "numberLike",
--[[3]] "whitespace",
--[[4]] "numberLike"
)
and not isSucceededBy(tokensOut, i+1, 1,
--[[1]] "colon",
--[[2]] "numberLike",
--[[3]] "whitespace",
--[[4]] "numberLike",
--[[5]] "whitespace",
--[[6]] "numberLike"
)
and tokensOut[i+2].type == tokensOut[i+4].type
and tokensOut[i+2].value == tokensOut[i+4].value
then
for j = i+4, i+3, -1 do
table.remove(tokensOut, j)
end
nextTokenIndex = i
return
end
-- Remove unit from number-likes inside some specific functions.
if
tokType == "function"
and token.value == "rotate3d"
and isSucceededBy(tokensOut, i+1, 1,
--[[1]] "numberLike",
--[[2]] "comma",
--[[3]] "numberLike",
--[[4]] "comma",
--[[5]] "numberLike",
--[[6]] ")"
)
and tokensOut[i+1].value == 0
and tokensOut[i+3].value == 0
and tokensOut[i+5].value == 0
then
tokensOut[i+1] = newTokenNumber(0)
tokensOut[i+3] = newTokenNumber(0)
tokensOut[i+5] = newTokenNumber(0)
-- nextTokenIndex = i -- No! We'll end up in an infinite loop.
return
end
end)
-- Shorten.
eachToken(tokensOut, nil, nil, nil, function(token, tokType, i)
--- #aabbcc -> #abc
--- Note: It seems CSS4 will add #RRGGBBAA and #RGBA formats, so this code will probably have to be updated.
if tokType == "hash" then
local colorHash = token.value
if
currentProperty
and isAt"rule"
and #colorHash == 6
and colorHash:byte(1) == colorHash:byte(2)
and colorHash:byte(3) == colorHash:byte(4)
and colorHash:byte(5) == colorHash:byte(6)
then
token.value = colorHash:gsub("(.).", "%1")
end
end
end)
-- Fix IE6 :first-line and :first-letter.
-- https://github.com/stoyan/yuicompressor/blob/master/ports/js/cssmin.js
--------------------------------
eachToken(tokensOut, #tokensOut-1, 2, -1, function(token, tokType, i)
if
tokensOut[i-1] and tokensOut[i+1]
and tokensOut[i].type == "ident" and isAny(tokensOut[i].value, "first-letter","first-line")
and tokensOut[i-1].type == "colon"
and (not tokensOut[i-2] or tokensOut[i-2].type ~= "colon")
and tokensOut[i+1].type ~= "whitespace"
-- isSucceededBy(tokensOut, #tokensOut, -1, "ident","first-letter", "colon", "!","colon") or
-- isSucceededBy(tokensOut, #tokensOut, -1, "ident","first-line", "colon", "!","colon")
then
table.insert(tokensOut, i+1, newTokenWhitespace(" "))
end
end)
-- Put @charset first.
--------------------------------
local charset = nil
eachToken(tokensOut, #tokensOut-1, 1, -1, function(token, tokType, i)
if
tokensOut[i+1]
and tokType == "atKeyword" and token.value == "charset"
and tokensOut[i+1].type == "string"
and (not tokensOut[i+2] or tokensOut[i+2].type == "semicolon")
then
if charset and tokensOut[i+1].value ~= charset then
if options.strict then
error(F("[css] Conflicting @charset values. ('%s' and '%s')", tokensOut[i+1].value, charset))
else
print(F("[css] Warning: Conflicting @charset values. ('%s' and '%s')", tokensOut[i+1].value, charset))
end
end
charset = tokensOut[i+1].value -- Note: We want the first charset value, and we're going backwards.
table.remove(tokensOut, i+1)
table.remove(tokensOut, i)
if tokensOut[i] then
table.remove(tokensOut, i)
end
end
end)
if charset then
table.insert(tokensOut, 1, {type="atKeyword", value="charset"})
table.insert(tokensOut, 2, newTokenWhitespace(" "))
table.insert(tokensOut, 3, {type="string", value=charset, quoteCharacter='"'})
table.insert(tokensOut, 4, {type="semicolon"})
end
--------------------------------
return tokensOut
end
--==============================================================
--= Tests ======================================================
--==============================================================
--[[
local function assertRange(from1, to1, from2, to2)
if from1 then
assert(to1)
if from1 ~= from2 then
error(tostring(from1).."-"..tostring(to1).." from="..tostring(from2), 2)
end
if to1 ~= to2 then
error(tostring(from1).."-"..tostring(to1).." to="..tostring(to2), 2)
end
else
assert(not to1)
if from2 then
error(tostring(from1).."-"..tostring(to1).." from="..tostring(from2), 2)
end
if to2 then
error(tostring(from1).."-"..tostring(to1).." to="..tostring(to2), 2)
end
end
end
assertRange(1, 0, matchWs("a c", 1))
assertRange(2, 2, matchWs("a c", 2))
assertRange(2, 1, matchWs("abc", 2))
-- print(".sÜи", utf8.codepoint(".sÜи", 1, 4))
assertRange(nil, nil, matchAlphaOrNonAscii("и.s.", #"и"+1))
assertRange(4, 4, matchAlphaOrNonAscii("и.s.", #"и"+2))
assertRange(4, 5, matchAlphaOrNonAscii("и.Ü.", #"и"+2))
assertRange(nil, nil, matchAlphaOrNonAscii(":7:", 2))
local token, ptr = consumeStringToken("a:'hel\\\nlo'", 4, "'")
assert(token.value == "hello", token.value)
assert(ptr == 12, ptr)
local token, ptr = consumeUrlToken("a:url(foo)", 7)
assert(token.value == "foo", token.value)
assert(ptr == 11, ptr)
local token, ptr = consumeUrlToken("a:url( 'foo' )", 7)
assert(token.value == "foo", token.value)
assert(ptr == 15, ptr)
local token, ptr = consumeUrlToken("a:url( 'fo\\\no' ", 8)
assert(token.value == "foo", token.value)
assert(ptr > 13, ptr)
local token, ptr = consumeUnicodeRangeToken(":12abCD; derp:", 2)
assert(token.from == 0x12ABCD, token.from)
assert(token.to == 0x12ABCD, token.to)
assert(ptr == 8, ptr)
local token, ptr = consumeUnicodeRangeToken(":12??????; derp:", 2)
assert(token.from == 0x120000, token.from)
assert(token.to == 0x12FFFF, token.to)
assert(ptr == 8, ptr)
local token, ptr = consumeUnicodeRangeToken("1234-5678", 1)
assert(token.from == 0x1234, token.from)
assert(token.to == 0x5678, token.to)
assert(ptr == 10, ptr)
local token, ptr = consumeUnicodeRangeToken("12??-5678", 1)
assert(token.from == 0x1200, token.from)
assert(token.to == 0x12FF, token.to)
assert(ptr == 5, ptr)
local cp, ptr = consumeEscape("\\001aBи789", 2)
assert(cp == 0x1AB, cp)
assert(ptr == 7, ptr)
local name, ptr = consumeName(":-foo;", 2)
assert(name == "-foo", name)
assert(ptr == 6, ptr)
local nRepr, n, nType, ptr = consumeNumber(":.6e+2;", 2)
assert(nRepr == ".6e+2", nRepr)
assert(n == .6e2, n)
assert(nType == "number", nType)
assert(ptr == 7, ptr)
local ptr = consumeRemnantsOfBadUrl(":url('foo\n');", 10)
assert(ptr == 13, ptr)
print("[css] All tests passed!")
os.exit(1) -- Not a "normal" run, thus the 1.
--]]
--[[
local function timeIt(loops, f, ...)
local clock = os.clock()
for i = 1, loops do
f(...)
end
return os.clock()-clock
end
-- ...
--]]
--==============================================================
--==============================================================
--==============================================================
return css
|
local vehicles = {}
function tvRP.spawnGarageVehicle(vtype,name,pos) -- vtype is the vehicle type (one vehicle per type allowed at the same time)
local vehicle = vehicles[vtype]
if vehicle and not IsVehicleDriveable(vehicle[3]) then -- precheck if vehicle is undriveable
-- despawn vehicle
SetVehicleHasBeenOwnedByPlayer(vehicle[3],false)
Citizen.InvokeNative(0xAD738C3085FE7E11, vehicle[3], false, true) -- set not as mission entity
SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(vehicle[3]))
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicle[3]))
vehicles[vtype] = nil
end
vehicle = vehicles[vtype]
if vehicle == nil then
-- load vehicle model
local mhash = GetHashKey(name)
local i = 0
while not HasModelLoaded(mhash) and i < 10000 do
RequestModel(mhash)
Citizen.Wait(10)
i = i+1
end
-- spawn car
if HasModelLoaded(mhash) then
local x,y,z = tvRP.getPosition()
if pos then
x,y,z = table.unpack(pos)
end
local nveh = CreateVehicle(mhash, x,y,z+0.5, 0.0, true, false)
NetworkFadeInEntity(nveh,0)
TriggerServerEvent("garage:requestMods", name)
SetVehicleOnGroundProperly(nveh)
SetEntityInvincible(nveh,false)
SetPedIntoVehicle(GetPlayerPed(-1),nveh,-1) -- put player inside
SetVehicleNumberPlateText(nveh, "P "..tvRP.getRegistrationNumber())
--Citizen.InvokeNative(0xAD738C3085FE7E11, nveh, true, true) -- set as mission entity
SetVehicleHasBeenOwnedByPlayer(nveh,true)
--Network vehicle set to allow migration by default
local nid = NetworkGetNetworkIdFromEntity(nveh)
SetNetworkIdCanMigrate(nid,cfg.vehicle_migration)
vehicles[vtype] = {vtype,name,nveh} -- set current vehicule
SetModelAsNoLongerNeeded(mhash)
end
else
tvRP.notify("Имате вече един "..vtype.." автомобил отвън.")
end
end
function tvRP.despawnGarageVehicle(vtype,max_range)
local vehicle = vehicles[vtype]
if vehicle then
local x,y,z = table.unpack(GetEntityCoords(vehicle[3],true))
local px,py,pz = tvRP.getPosition()
if GetDistanceBetweenCoords(x,y,z,px,py,pz,true) < max_range then -- check distance with the vehicule
-- remove vehicle
SetVehicleHasBeenOwnedByPlayer(vehicle[3],false)
Citizen.InvokeNative(0xAD738C3085FE7E11, vehicle[3], false, true) -- set not as mission entity
SetVehicleAsNoLongerNeeded(Citizen.PointerValueIntInitialized(vehicle[3]))
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicle[3]))
vehicles[vtype] = nil
tvRP.notify("Автомобила е прибран.")
else
tvRP.notify("Твърде сте дълеч от автомобила.")
end
end
end
-- check vehicles validity
--[[
Citizen.CreateThread(function()
Citizen.Wait(30000)
for k,v in pairs(vehicles) do
if IsEntityAVehicle(v[3]) then -- valid, save position
v.pos = {table.unpack(GetEntityCoords(vehicle[3],true))}
elseif v.pos then -- not valid, respawn if with a valid position
print("[vRP] invalid vehicle "..v[1]..", respawning...")
tvRP.spawnGarageVehicle(v[1], v[2], v.pos)
end
end
end)
--]]
-- (experimental) this function return the nearest vehicle
-- (don't work with all vehicles, but aim to)
function tvRP.getNearestVehicle(radius)
local x,y,z = tvRP.getPosition()
local ped = GetPlayerPed(-1)
if IsPedSittingInAnyVehicle(ped) then
return GetVehiclePedIsIn(ped, true)
else
-- flags used:
--- 8192: boat
--- 4096: helicos
--- 4,2,1: cars (with police)
local veh = GetClosestVehicle(x+0.0001,y+0.0001,z+0.0001, radius+0.0001, 0, 8192+4096+4+2+1) -- boats, helicos
if not IsEntityAVehicle(veh) then veh = GetClosestVehicle(x+0.0001,y+0.0001,z+0.0001, radius+0.0001, 0, 4+2+1) end -- cars
return veh
end
end
function tvRP.fixeNearestVehicle(radius)
local veh = tvRP.getNearestVehicle(radius)
if IsEntityAVehicle(veh) then
SetVehicleFixed(veh)
end
end
function tvRP.replaceNearestVehicle(radius)
local veh = tvRP.getNearestVehicle(radius)
if IsEntityAVehicle(veh) then
SetVehicleOnGroundProperly(veh)
end
end
-- try to get a vehicle at a specific position (using raycast)
function tvRP.getVehicleAtPosition(x,y,z)
x = x+0.0001
y = y+0.0001
z = z+0.0001
local ray = CastRayPointToPoint(x,y,z,x,y,z+4,10,GetPlayerPed(-1),0)
local a, b, c, d, ent = GetRaycastResult(ray)
return ent
end
-- return ok,vtype,name
function tvRP.getNearestOwnedVehicle(radius)
local px,py,pz = tvRP.getPosition()
for k,v in pairs(vehicles) do
local x,y,z = table.unpack(GetEntityCoords(v[3],true))
local dist = GetDistanceBetweenCoords(x,y,z,px,py,pz,true)
if dist <= radius+0.0001 then return true,v[1],v[2] end
end
return false,"",""
end
-- return ok,x,y,z
function tvRP.getAnyOwnedVehiclePosition()
for k,v in pairs(vehicles) do
if IsEntityAVehicle(v[3]) then
local x,y,z = table.unpack(GetEntityCoords(v[3],true))
return true,x,y,z
end
end
return false,0,0,0
end
-- return x,y,z
function tvRP.getOwnedVehiclePosition(vtype)
local vehicle = vehicles[vtype]
local x,y,z = 0,0,0
if vehicle then
x,y,z = table.unpack(GetEntityCoords(vehicle[3],true))
end
return x,y,z
end
-- return ok, vehicule network id
function tvRP.getOwnedVehicleId(vtype)
local vehicle = vehicles[vtype]
if vehicle then
return true, NetworkGetNetworkIdFromEntity(vehicle[3])
else
return false, 0
end
end
-- eject the ped from the vehicle
function tvRP.ejectVehicle()
local ped = GetPlayerPed(-1)
if IsPedSittingInAnyVehicle(ped) then
local veh = GetVehiclePedIsIn(ped,false)
TaskLeaveVehicle(ped, veh, 4160)
end
end
-- vehicle commands
function tvRP.vc_openDoor(vtype, door_index)
local vehicle = vehicles[vtype]
if vehicle then
SetVehicleDoorOpen(vehicle[3],door_index,0,false)
end
end
function tvRP.vc_closeDoor(vtype, door_index)
local vehicle = vehicles[vtype]
if vehicle then
SetVehicleDoorShut(vehicle[3],door_index)
end
end
function tvRP.vc_detachTrailer(vtype)
local vehicle = vehicles[vtype]
if vehicle then
DetachVehicleFromTrailer(vehicle[3])
end
end
function tvRP.vc_detachTowTruck(vtype)
local vehicle = vehicles[vtype]
if vehicle then
local ent = GetEntityAttachedToTowTruck(vehicle[3])
if IsEntityAVehicle(ent) then
DetachVehicleFromTowTruck(vehicle[3],ent)
end
end
end
function tvRP.vc_detachCargobob(vtype)
local vehicle = vehicles[vtype]
if vehicle then
local ent = GetVehicleAttachedToCargobob(vehicle[3])
if IsEntityAVehicle(ent) then
DetachVehicleFromCargobob(vehicle[3],ent)
end
end
end
function tvRP.vc_toggleEngine(vtype)
local vehicle = vehicles[vtype]
if vehicle then
local running = Citizen.InvokeNative(0xAE31E7DF9B5B132E,vehicle[3]) -- GetIsVehicleEngineRunning
SetVehicleEngineOn(vehicle[3],not running,true,true)
if running then
SetVehicleUndriveable(vehicle[3],true)
else
SetVehicleUndriveable(vehicle[3],false)
end
end
end
function tvRP.vc_toggleLock(vtype)
local vehicle = vehicles[vtype]
if vehicle then
local veh = vehicle[3]
local locked = GetVehicleDoorLockStatus(veh) >= 2
if locked then -- unlock
SetVehicleDoorsLockedForAllPlayers(veh, false)
SetVehicleDoorsLocked(veh,1)
SetVehicleDoorsLockedForPlayer(veh, PlayerId(), false)
tvRP.notify("Автомобила е отключен.")
else -- lock
SetVehicleDoorsLocked(veh,2)
SetVehicleDoorsLockedForAllPlayers(veh, true)
tvRP.notify("Автомобила е заключен.")
end
end
end
function tvRP.garage_setmods(mods)
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsUsing(ped)
local a = string.find(mods, ":")
local ct = 0
SetVehicleModKit(veh,0)
while mods ~= nil do
local b
if a ~= nil then
b = mods:sub(0,a-1)
mods = mods:sub(a+1)
a = string.find(mods, ":")
else
b = mods
mods = nil
end
local u = string.find(b, ",")
if ct == 0 then
local u1 = b:sub(0,u-1)
local u2 = b:sub(u+1)
SetVehicleColours(veh,tonumber(u1),tonumber(u2))
elseif ct == 1 then
local u1 = b:sub(0,u-1)
local u2 = b:sub(u+1)
SetVehicleExtraColours(veh,tonumber(u1),tonumber(u2))
elseif ct == 2 then
local u1 = b:sub(0,u-1)
local u2 = b:sub(u+1)
local spl = string.find(u2, ",")
local u3 = u2:sub(spl+1)
u2 = u2:sub(0,spl-1)
SetVehicleNeonLightsColour(veh,tonumber(u1),tonumber(u2),tonumber(u3))
elseif ct == 3 then
local bl = false
if tostring(b) == "true" then bl = true end
SetVehicleNeonLightEnabled(veh,0,bl)
SetVehicleNeonLightEnabled(veh,1,bl)
SetVehicleNeonLightEnabled(veh,2,bl)
SetVehicleNeonLightEnabled(veh,3,bl)
elseif ct == 4 then
local u1 = b:sub(0,u-1)
local u2 = b:sub(u+1)
local spl = string.find(u2, ",")
local u3 = u2:sub(spl+1)
u2 = u2:sub(0,spl-1)
SetVehicleTyreSmokeColor(veh,tonumber(u1),tonumber(u2),tonumber(u3))
elseif ct == 5 then
SetVehicleNumberPlateTextIndex(veh,tonumber(b))
elseif ct == 6 then
SetVehicleWindowTint(veh,tonumber(b))
elseif ct == 7 then
SetVehicleWheelType(veh,tonumber(b))
elseif ct == 8 then
local bl = false
if tostring(b) == "true" then bl = true end
SetVehicleTyresCanBurst(veh,bl)
elseif ct == 9 then
local c = string.find(b, ";")
while b ~= nil do
local d
if c ~= nil then
d = b:sub(0,c-1)
b = b:sub(c+1)
c = string.find(b, ";")
else
d = b
b = nil
end
if d ~= nil then
local u = string.find(d, ",")
local u1 = d:sub(0,u-1)
local u2 = d:sub(u+1)
local spl = string.find(u2, ",")
local u3 = u2:sub(spl+1)
u2 = u2:sub(0,spl-1)
local bl = false
if tostring(u3) == "true" then bl = true end
if tonumber(u1) == 18 or tonumber(u1) == 22 or tonumber(u1) == 20 then
ToggleVehicleMod(veh,tonumber(u1),bl)
SetVehicleMod(veh,tonumber(u1),tonumber(u2),bl)
else
SetVehicleMod(veh,tonumber(u1),tonumber(u2),bl)
end
end
end
end
ct = ct+1
end
end |
include("sourcenet/querycvar.lua")
function FindPlayerByNetChannel(netchan)
for k, v in pairs(player.GetAll()) do
if netchan == CNetChan(v:EntIndex()) then
return v
end
end
end
hook.Add("PlayerInitialSpawn", "InitialCheatsCheck", function(ply)
ply.CheatsCookie = ply:QueryConVarValue("sv_cheats")
end)
hook.Add("RespondCvarValue", "InitialCheatsCheck", function(netchan, cookie, status, cvarname, cvarvalue)
if status ~= 0 then return end
if cvarname ~= "sv_cheats" then return end
if cvarvalue == GetConVarString("sv_cheats") then return end
local ply = FindPlayerByNetChannel(netchan)
if IsValid(ply) and cookie == ply.CheatsCookie then
ply:Kick("Incorrect sv_cheats value")
end
end)
|
local E, L, V, P, G = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
local UF = E:GetModule('UnitFrames')
gpsRestricted = nil
function UF:Construct_Unit_GPS(frame, unit)
if not frame then return end
local gps = CreateFrame("Frame", nil, frame, 'BackdropTemplate')
gps:SetTemplate("Transparent")
gps:EnableMouse(false)
gps:SetFrameLevel(frame:GetFrameLevel() + 100)
gps:Size(48, 13)
gps:SetAlpha(.7)
gps.Texture = gps:CreateTexture(nil, "OVERLAY")
gps.Texture:SetTexture([[Interface\AddOns\ElvUI_Enhanced\media\textures\arrow.tga]])
gps.Texture:Size(12, 12)
gps.Texture:SetPoint("LEFT", gps, "LEFT", 0, 0)
gps.Text = gps:CreateFontString(nil, "OVERLAY")
gps.Text:FontTemplate(E.media.font, 12, 'OUTLINE')
gps.Text:SetPoint("RIGHT", gps, "RIGHT", 0 , 0)
UF:Configure_FontString(gps.Text)
gps.unit = unit
--gps:Hide()
gps:Show()
frame.gps = gps
UF:CreateAndUpdateUF(unit)
end
function UF:Construct_HealGlow(frame)
frame:CreateShadow()
local x = frame.shadow
frame.shadow = nil
x:Hide()
return x
end
function UF:AddShouldIAttackIcon(frame)
if not frame then return end
local tag = CreateFrame("Frame", nil, frame)
tag:SetFrameLevel(frame:GetFrameLevel() + 8)
tag:EnableMouse(false)
local size = frame.Health and frame.Health:GetHeight() - 16 or 24
tag:Size(size, size)
tag:SetAlpha(.5)
tag.tx = tag:CreateTexture(nil, "OVERLAY")
tag.tx:SetTexture([[Interface\AddOns\ElvUI_Enhanced\media\textures\shield.tga]])
tag.tx:SetAllPoints()
tag.db = E.db.unitframe.units.target.attackicon
tag:RegisterEvent("PLAYER_TARGET_CHANGED")
tag:RegisterEvent("UNIT_COMBAT")
tag:SetScript("OnEvent", function()
--if UnitIsTapped("target") and not (UnitIsTappedByPlayer("target") or UnitIsTappedByAllThreatList("target")) then
--tag:Hide
--end
--if UnitCanAttack("player", "target") and (not UnitIsTapped("target") or UnitIsTappedByAllThreatList("target")) then
-- tag:Show()
--else
-- tag:Hide()
--end
if tag.db.enable and not UnitIsDeadOrGhost("target") and UnitCanAttack("player", "target") and UnitIsTapDenied("target") then
tag:ClearAllPoints()
tag:SetPoint("CENTER", frame, "CENTER", tag.db.xOffset, tag.db.yOffset)
tag:Show()
else
tag:Hide()
end
end)
end
function UF:EnhanceUpdateRoleIcon()
local frameGroups = {5, 25, 40}
local frame
for _, index in ipairs(frameGroups) do
for i=1, (index/5) do
for j=1, 5 do
frame = (index == 5 and _G[("ElvUF_PartyGroup%dUnitButton%i"):format(i, j)] or index == 25 and _G[("ElvUF_RaidGroup%dUnitButton%i"):format(i, j)] or _G[("ElvUF_Raid%dGroup%dUnitButton%i"):format(index, i, j)])
if frame then
UF:UpdateRoleIconFrame(frame, ((index == 5 and 'party%d' or index == 25 and 'raid' or 'raid%d')):format(i))
end
end
end
end
--UF:UpdateAllHeaders()
end
function UF:UpdateRoleIconFrame(frame)
if not frame then return end
if not frame.LFDRole then return end
if E.db.unitframe.hideroleincombat then
local p = frame.LFDRole:GetParent()
local f = CreateFrame('Frame', nil, p)
frame.LFDRole:SetParent(f)
RegisterStateDriver(f, 'visibility', '[combat]hide;show')
end
end
function UF:ApplyUnitFrameEnhancements()
UF:ScheduleTimer("checkGpsRestriction", 6)
UF:ScheduleTimer("AddShouldIAttackIcon", 8, _G["ElvUF_Target"])
UF:ScheduleTimer("Construct_Unit_GPS", 10, _G["ElvUF_Target"], 'target')
UF:ScheduleTimer("Construct_Unit_GPS", 12, _G["ElvUF_Focus"], 'focus')
UF:ScheduleTimer("EnhanceUpdateRoleIcon", 15)
UF:RegisterEvent("ZONE_CHANGED_NEW_AREA", "checkGpsRestriction")
UF:RegisterEvent("ZONE_CHANGED", "checkGpsRestriction")
UF:RegisterEvent("ZONE_CHANGED_INDOORS", "checkGpsRestriction")
end
function UF:checkGpsRestriction()
gpsRestricted, _ = IsInInstance()
--UF:CreateAndUpdateUF("target")
--UF:CreateAndUpdateUF("focus")
end
local CF = CreateFrame('Frame')
CF:RegisterEvent("PLAYER_ENTERING_WORLD")
CF:SetScript("OnEvent", function(self, event)
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
if not E.private["unitframe"].enable then return end
UF:ScheduleTimer("ApplyUnitFrameEnhancements", 5)
end) |
do
kAlienTechMap[#kAlienTechMap+1] = { kTechId.DrifterRegeneration, 5, 3 }
kAlienTechMap[#kAlienTechMap+1] = { kTechId.DrifterCamouflage, 8, 3 }
kAlienTechMap[#kAlienTechMap+1] = { kTechId.DrifterCelerity, 11, 3 }
kAlienLines[#kAlienLines+1] = GetLinePositionForTechMap(kAlienTechMap, kTechId.CragHive, kTechId.DrifterRegeneration)
kAlienLines[#kAlienLines+1] = GetLinePositionForTechMap(kAlienTechMap, kTechId.ShadeHive, kTechId.DrifterCamouflage)
kAlienLines[#kAlienLines+1] = GetLinePositionForTechMap(kAlienTechMap, kTechId.ShiftHive, kTechId.DrifterCelerity)
end |
sideQuests = {
[1] = { -- Plant 5 seeds in oliver's house
type = 'type:plant;oliver',
amount = 5,
points = 6,
},
[2] = { -- Fertilize 5 plants in oliver's house
type = 'type:fertilize;oliver',
amount = 5,
points = 2,
},
[3] = { -- Get 5000 coins
type = 'type:coins;get',
amount = 5000,
points = 7,
},
[4] = { -- Arrest a thief 3 times
type = 'arrest',
amount = 3,
points = 3,
},
[5] = { -- Use 15 items
type = 'type:items;use',
amount = 15,
points = 5,
},
[6] = { -- Spend 2000 coins
type = 'type:coins;use',
amount = 2000,
points = 1,
},
[7] = { -- Fish 10 times
type = 'type:fish',
amount = 10,
points = 3,
},
[8] = { -- Get 5 Gold Nuggets [removed]
amount = 1,
points = 1,
alias = 5
},
[9] = { -- Rob the bank without getting arrested
type = 'bank',
amount = 1,
points = 13,
},
[10] = { -- Rob 3 times
type = 'rob',
amount = 3,
points = 5,
},
[11] = { -- Cook 3 times
type = 'type:cook',
amount = 3,
points = 3,
},
[12] = { -- Earn 1000 xp
type = 'getXP',
amount = 1000,
points = 10,
},
[13] = { -- Fish 4 frogs
type = 'type:fish;fish_Frog',
amount = 4,
points = 3,
},
[14] = { -- Fish a Lionfish
type = 'type:fish;fish_Lionfish',
amount = 1,
points = 5,
},
[15] = { -- Deliver 5 orders
type = 'deliver',
amount = 5,
points = 10,
},
[16] = { -- Deliver 10 orders
type = 'deliver',
amount = 10,
points = 23,
},
[17] = { -- Cook a pizza
type = 'type:cook;pizza',
amount = 1,
points = 3,
},
[18] = { -- Cook a bruschetta
type = 'type:cook;bruschetta',
amount = 1,
points = 3,
},
[19] = { -- Make a lemonade
type = 'type:cook;lemonade',
amount = 1,
points = 2,
},
[20] = { -- Cook a frogwich
type = 'type:cook;frogSandwich',
amount = 1,
points = 2,
},
[21] = { -- Plant 2 seeds in oliver's house
amount = 2,
points = 1,
alias = 1,
},
[22] = { -- Plant 10 seeds in oliver's house
amount = 10,
points = 10,
alias = 1,
},
[23] = { -- Fertilize 3 plants in oliver's house
amount = 3,
points = 2,
alias = 2,
},
[24] = { -- Fertilize 10 plants in oliver's house
amount = 10,
points = 6,
alias = 2,
},
[25] = { -- Get 1000 coins
amount = 1000,
points = 2,
alias = 3,
},
[26] = { -- Get 10000 coins
amount = 10000,
points = 20,
alias = 3,
},
[27] = { -- Fish 3 times
amount = 3,
points = 1,
alias = 7,
},
[28] = { -- Arrest a thief 6 times
amount = 6,
points = 6,
alias = 4,
},
[29] = { -- Deliver 2 orders
amount = 2,
points = 2,
alias = 16,
},
[30] = { -- Use 5 items
amount = 5,
points = 1,
alias = 5,
},
[31] = { -- Sell [Amount] crystals
type = 'sell_crystal',
amount = {2, 5, 10},
points = {2, 4, 6},
},
[32] = { -- Trade with Dave [Amount] times
type = 'trade_with_dave',
amount = {2, 3, 5},
points = {1, 2, 3},
},
[33] = { -- Harvest [Amount] crops
type = 'harvest',
amount = {2, 5, 10},
points = {1, 3, 5},
},
[34] = { -- Sell [Amount] seeds.
type = 'sell_seeds',
amount = {3, 5, 10},
points = {1, 2, 3},
},
[35] = { -- Sell [Amount] fruits.
type = 'sell_fruits',
amount = {10, 15, 20},
points = {2, 3, 4},
},
[36] = { -- Sell [Amount] fishes.
type = 'sell_fishes',
amount = {5, 10, 15},
points = {1, 2, 3},
},
[37] = { -- Rob [NPC] [Amount] times.
type = 'rob_npc',
amount = {2, 5},
points = {2, 5},
extraData = function()
return table_randomKey(gameNpcs.robbing)
end,
formatDescription = function(player)
local playerData = players[player]
local npc = "<vp>".. playerData.sideQuests[8] .."</vp>"
local amount = "<vp>".. playerData.sideQuests[2] .. '/'.. playerData.sideQuests[7] .."</vp>"
return {npc, amount}
end
},
[38] = { -- Buy [Amount] items from [NPC].
type = 'buy_from_npc',
amount = {2, 5, 8},
points = {1, 2, 3},
extraData = function()
return table_randomKey(gameNpcs.selling)
end,
formatDescription = function(player)
local playerData = players[player]
local npc = "<vp>".. playerData.sideQuests[8] .."</vp>"
local amount = "<vp>".. playerData.sideQuests[2] .. '/'.. playerData.sideQuests[7] .."</vp>"
return {amount, npc}
end
},
}
for i, v in next, sideQuests do
if v.alias then
v.type = sideQuests[v.alias].type
end
end |
local __is = {}
function __is:__index(key)
self[key] = function(value)
if type(value) == tostring(key) then
return true, value
else
return false, key .. " expected, got " .. type(value)
end
end
return self[key]
end
local is = {}
is["nil"] = function(value)
if value == nil then
return true, value
else
return false, "nil expected, got " .. type(value)
end
end
return setmetatable(is, __is)
|
--[[
Upbit Open API
## REST API for Upbit Exchange - Base URL: [https://api.upbit.com] - Official Upbit API Documents: [https://docs.upbit.com] - Official Support email: [open-api@upbit.com]
OpenAPI spec version: 1.0.0
Contact: ujhin942@gmail.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
]]
-- deposit_complete_response class
local deposit_complete_response = {}
local deposit_complete_response_mt = {
__name = "deposit_complete_response";
__index = deposit_complete_response;
}
local function cast_deposit_complete_response(t)
return setmetatable(t, deposit_complete_response_mt)
end
local function new_deposit_complete_response(currency, deposit_address, secondary_address)
return cast_deposit_complete_response({
["currency"] = currency;
["deposit_address"] = deposit_address;
["secondary_address"] = secondary_address;
})
end
return {
cast = cast_deposit_complete_response;
new = new_deposit_complete_response;
}
|
-- Toggable tray, for those who don't like to see it all the time.
-- http://awesome.naquadah.org/wiki/Minitray
-- Usage: after requiring a module, bind minitray.toggle() to a key.
local wibox = require("wibox")
-- Module minitray
local minitray = { geometry = {} }
local function show()
local scrgeom = screen[mouse.screen].workarea
minitray.wibox.height = minitray.geometry.height or 20
local items = awesome.systray()
if items == 0 then items = 1 end
minitray.wibox.width = minitray.geometry.width or (minitray.wibox.height * items)
minitray.wibox:geometry({ x = minitray.geometry.x or (scrgeom.width - scrgeom.x - minitray.wibox.width),
y = minitray.geometry.y or scrgeom.y })
minitray.wibox.visible = true
end
local function init()
minitray.wibox = wibox({})
minitray.wibox.ontop = true
minitray.layout = wibox.layout.align.horizontal()
minitray.tray = wibox.widget.systray()
minitray.layout:set_right(minitray.tray)
minitray.wibox:set_widget(minitray.layout)
end
local function hide()
minitray.wibox.visible = false
end
function minitray.toggle(geometry)
if geometry then
minitray.geometry = geometry
end
if not minitray.wibox then
init()
end
if minitray.wibox.visible then
hide()
else
show()
end
end
return minitray |
-- ========== THIS IS AN AUTOMATICALLY GENERATED FILE! ==========
PlaceObj('XTemplate', {
__is_kind_of = "XTextButton",
group = "Paradox",
id = "ParadoxUIComboButton",
PlaceObj('XTemplateWindow', {
'__class', "XTextButton",
'Dock', "right",
'Background', RGBA(255, 255, 255, 0),
'MouseCursor', "UI/Cursors/Rollover.tga",
'FocusedBackground', RGBA(255, 255, 255, 0),
'RolloverBackground', RGBA(255, 255, 255, 0),
'PressedBackground', RGBA(255, 255, 255, 0),
'Icon', "UI/Mods/triangle2.tga",
'IconRows', 2,
'IconRow', 2,
}),
})
|
data:extend({
{
type = "item-subgroup",
name = "LTN-signal",
group = "signals",
order = "z[LTN-signal]"
},
{
type = "virtual-signal",
name = "min-train-length",
icon = "__"..MOD_NAME.."__/graphics/icons/min-train-length.png",
subgroup = "LTN-signal",
order = "z[LTN-signal]-aa[min-train-length]"
},
{
type = "virtual-signal",
name = "max-train-length",
icon = "__"..MOD_NAME.."__/graphics/icons/max-train-length.png",
subgroup = "LTN-signal",
order = "z[LTN-signal]-ab[max-train-length]"
},
{
type = "virtual-signal",
name = "min-delivery-size",
icon = "__"..MOD_NAME.."__/graphics/icons/min-shipment-size.png",
subgroup = "LTN-signal",
order = "z[LTN-signal]-ac[min-delivery-size]"
},
{
type = "virtual-signal",
name = "stop-priority",
icon = "__"..MOD_NAME.."__/graphics/icons/stop-priority.png",
subgroup = "LTN-signal",
order = "z[LTN-signal]-ad[stop-priority]"
},
{
type = "virtual-signal",
name = "ltn-depot",
icon = "__"..MOD_NAME.."__/graphics/icons/depot.png",
subgroup = "LTN-signal",
order = "z[LTN-signal]-ae[ltn-depot]"
}
}) |
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by vdatcu.
--- DateTime: 05/07/2018 11:04
---
local CLASS_UNDER_TEST = 'api-gateway.redis.redisHealthCheck'
local ngxUpstreamMock, ngxSocketMock, shared
beforeEach(function()
ngxUpstreamMock = mock('ngx.upstream', { 'get_primary_peers', 'get_backup_peers' })
ngxSocketMock = mock('ngx.socket.tcp', { 'connect', 'receive', 'send', 'close', 'settimeout' })
ngx.socket = {
tcp = function()
return ngxSocketMock
end
}
shared = mock("ngx.shared", { "safe_set", "delete", "get" })
ngx.shared = {
cachedOauthTokens = shared
}
end)
test('Successful flow with no password, should return one healthy host', function()
local classUnderTest = require(CLASS_UNDER_TEST):new()
ngxUpstreamMock.__get_primary_peers.doReturn = function()
local primaryPeers = {}
table.insert(primaryPeers, { name = "127.0.0.1:6379" })
return primaryPeers, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return {}, nil
end
ngxSocketMock.__connect.doReturn = function()
return true, nil
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', '')
assertNotNil(healthyHost)
assertNotNil(host)
assertNotNil(port)
assertEquals('127.0.0.1', host)
assertEquals('6379', tostring(port))
end)
test('Successful flow with password, should return one healthy host', function()
local classUnderTest = require(CLASS_UNDER_TEST):new()
ngxUpstreamMock.__get_primary_peers.doReturn = function()
local primaryPeers = {}
table.insert(primaryPeers, { name = "127.0.0.1:6379" })
return primaryPeers, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return {}, nil
end
ngxSocketMock.__connect.doReturn = function()
return true, nil
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNotNil(healthyHost)
assertNotNil(host)
assertNotNil(port)
assertEquals('127.0.0.1', host)
assertEquals('6379', tostring(port))
end)
test('Faulty flow with wrong password, should not return any host', function()
ngx.var["enable_redis_advanced_healthcheck"] = "true"
local classUnderTest = require(CLASS_UNDER_TEST):new()
ngxUpstreamMock.__get_primary_peers.doReturn = function()
local primaryPeers = {}
table.insert(primaryPeers, { name = "127.0.0.1:6379" })
return primaryPeers, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return {}, nil
end
ngxSocketMock.__connect.doReturn = function()
return true, nil
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'ERROR', 'ERROR', nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNil(healthyHost)
assertNil(host)
assertNil(port)
end)
test('Backup peers successful flow with password, should return one healthy host', function()
local classUnderTest = require(CLASS_UNDER_TEST):new()
ngxUpstreamMock.__get_primary_peers.doReturn = function()
return {}, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
local secondaryPeers = {}
table.insert(secondaryPeers, { name = "127.0.0.1:6379" })
return secondaryPeers, nil
end
ngxSocketMock.__connect.doReturn = function()
return true, nil
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNotNil(healthyHost)
assertNotNil(host)
assertNotNil(port)
assertEquals('127.0.0.1', host)
assertEquals('6379', tostring(port))
end)
test('Multiple peers successful flow with password, should return first healthy host', function()
ngx.var["enable_redis_advanced_healthcheck"] = "true"
local classUnderTest = require(CLASS_UNDER_TEST):new()
local primaryPeers = {
{
name = "127.0.0.2:7000"
},
{
name = "127.0.0.1.6379"
}
}
ngxUpstreamMock.__get_primary_peers.doReturn = function()
return primaryPeers, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return {}, nil
end
ngxSocketMock.__connect.doReturn = function()
return true, nil
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNotNil(healthyHost)
assertNotNil(host)
assertNotNil(port)
assertEquals(primaryPeers[1].name, healthyHost)
assertEquals('127.0.0.2', host)
assertEquals('7000', tostring(port))
end)
test('No tcp connection should fail', function()
ngx.var["enable_redis_advanced_healthcheck"] = "true"
local classUnderTest = require(CLASS_UNDER_TEST):new()
local primaryPeers = {
{
name = "127.0.0.2:7000"
},
{
name = "127.0.0.1.6379"
}
}
ngxUpstreamMock.__get_primary_peers.doReturn = function()
return primaryPeers, nil
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return {}, nil
end
ngxSocketMock.__connect.doReturn = function()
return false, {}
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNil(healthyHost)
assertNil(host)
assertNil(port)
end)
test('Primary and backup peers error should fail', function()
local classUnderTest = require(CLASS_UNDER_TEST):new()
ngxUpstreamMock.__get_primary_peers.doReturn = function()
return nil, 'ERROR'
end
ngxUpstreamMock.__get_backup_peers.doReturn = function()
return nil, 'ERROR'
end
ngxSocketMock.__connect.doReturn = function()
return false, {}
end
ngxSocketMock.__settimeout.doReturn = function()
return true
end
ngxSocketMock.__send.doReturn = function(self, message)
if string.match(message, 'AUTH') then
ngxSocketMock.__receive.doReturn = function()
return 'OK', nil, nil
end
end
if string.match(message, 'PING') then
ngxSocketMock.__receive.doReturn = function()
return 'PONG', nil, nil
end
end
return 0, nil
end
local healthyHost, host, port = classUnderTest:getHealthyRedisNode('api-gateway-read-replica', 'password')
assertNil(healthyHost)
assertNil(host)
assertNil(port)
end)
|
--
-- PianoRollMainView.lua
--
require "Common"
if language() == "fr" then
currentVelocityStr = "Vél.:"
controllerProgramChangesStr = "PC"
controllerPitchBendStr = "PB"
controllerKeyAftertouchStr = "KAT"
controllerChannelAftertouchStr = "CAT"
controllerSysexStr = "SYSEX"
controllerControlChangeStr = "CC"
controllerMetaTypeStr = "META"
controllerProgramChangesTooltipStr = "Program Change"
controllerPitchBendTooltipStr = "Pitch Bend"
controllerKeyAftertouchTooltipStr = "Key Aftertouch"
controllerChannelAftertouchTooltipStr = "Channel Aftertouch"
controllerSysexTooltipStr = "System Exclusive"
controllerControlChangeTooltipStr = "Control Change (Sustain, Modulation, etc.)"
controllerMetaTypeTooltipStr = "Meta (Tempo, Time Signature, etc.)"
else
currentVelocityStr = "Vel.:"
controllerProgramChangesStr = "PC"
controllerTempoStr = "T"
controllerPitchBendStr = "PB"
controllerKeyAftertouchStr = "KAT"
controllerChannelAftertouchStr = "CAT"
controllerSysexStr = "SYSEX"
controllerControlChangeStr = "CC"
controllerMetaTypeStr = "META"
controllerProgramChangesTooltipStr = "Program Change"
controllerTempoTooltipStr = "Tempo"
controllerPitchBendTooltipStr = "Pitch Bend"
controllerKeyAftertouchTooltipStr = "Key Aftertouch"
controllerChannelAftertouchTooltipStr = "Channel Aftertouch"
controllerSysexTooltipStr = "System Exclusive"
controllerControlChangeTooltipStr = "Control Change (Sustain, Modulation, etc.)"
controllerMetaTypeTooltipStr = "Meta (Tempo, Time Signature, etc.)"
end
|
return {
code = 605,
key = "NO_INTERACTION_COMPONENT",
} |
------------------------------------------------------------------------
--[[ Recursor ]]--
-- Decorates module to be used within an AbstractSequencer.
-- It does this by making the decorated module conform to the
-- AbstractRecurrent interface (which is inherited by LSTM/Recurrent)
------------------------------------------------------------------------
local Recursor, parent = torch.class('nn.Recursor', 'nn.AbstractRecurrent')
function Recursor:__init(module, rho)
parent.__init(self, rho or 9999999)
self.recurrentModule = module
self.module = module
self.modules = {module}
self.sharedClones[1] = self.recurrentModule
end
function Recursor:updateOutput(input)
local output
if self.train ~= false then -- if self.train or self.train == nil then
-- set/save the output states
self:recycle()
local recurrentModule = self:getStepModule(self.step)
output = recurrentModule:updateOutput(input)
else
output = self.recurrentModule:updateOutput(input)
end
self.outputs[self.step] = output
self.output = output
self.step = self.step + 1
self.updateGradInputStep = nil
self.accGradParametersStep = nil
return self.output
end
function Recursor:_updateGradInput(input, gradOutput)
assert(self.step > 1, "expecting at least one updateOutput")
local step = self.updateGradInputStep - 1
assert(step >= 1)
local recurrentModule = self:getStepModule(step)
recurrentModule:setOutputStep(step)
local gradInput = recurrentModule:updateGradInput(input, gradOutput)
return gradInput
end
function Recursor:_accGradParameters(input, gradOutput, scale)
local step = self.accGradParametersStep - 1
assert(step >= 1)
local recurrentModule = self:getStepModule(step)
recurrentModule:setOutputStep(step)
recurrentModule:accGradParameters(input, gradOutput, scale)
end
function Recursor:includingSharedClones(f)
local modules = self.modules
self.modules = {}
local sharedClones = self.sharedClones
self.sharedClones = nil
for i,modules in ipairs{modules, sharedClones} do
for j, module in pairs(modules) do
table.insert(self.modules, module)
end
end
local r = {f()}
self.modules = modules
self.sharedClones = sharedClones
return unpack(r)
end
function Recursor:forget(offset)
parent.forget(self, offset)
nn.Module.forget(self)
return self
end
function Recursor:maxBPTTstep(rho)
self.rho = rho
nn.Module.maxBPTTstep(self, rho)
end
function Recursor:getHiddenState(...)
return self.modules[1]:getHiddenState(...)
end
function Recursor:setHiddenState(...)
return self.modules[1]:setHiddenState(...)
end
function Recursor:getGradHiddenState(...)
return self.modules[1]:getGradHiddenState(...)
end
function Recursor:setGradHiddenState(...)
return self.modules[1]:setGradHiddenState(...)
end
Recursor.__tostring__ = nn.Decorator.__tostring__
|
-- data handler for RGB-IR images
--
-- David-Alexandre Beaupre
--
require 'image'
require 'cutorch'
require 'gnuplot'
require 'xlua'
require 'math'
require 'io'
local TestDataHandler = torch.class('TestDataHandler')
function TestDataHandler:__init(data_root, testing, img_nb, psz, half_range, fold, gpu, offset)
self.fold = fold
self.channels = 3
self.psz = psz
self.pSize = 2 * psz + 1
self.half_range = half_range
self.cuda = gpu or 1
local name = string.format('%s', testing)
local file = io.open(name, 'r')
local size = file:seek('end')
-- every entry in binary file is 4 bytes
size = size / 4
self.locations = torch.FloatTensor(torch.FloatStorage(name, false, size)):view(-1,5)
self.rgb = {}
self.lwir = {}
self.permutations = torch.randperm((#self.locations)[1])
nb_points = (#self.locations)[1]
print(string.format('#testing locations: %d ', (#self.locations)[1]))
-- load and normalize test images
for i = offset, img_nb + offset - 1 do
j = i - offset
xlua.progress(j + 1, img_nb)
local rgb = image.load(string.format('%s/test/rgb/%d.png', data_root, i), self.channels, 'byte'):float()
local lwir = image.load(string.format('%s/test/lwir/%d.png', data_root, i), self.channels, 'byte'):float()
rgb:add(-rgb:mean()):div(rgb:std())
lwir:add(-lwir:mean()):div(lwir:std())
self.rgb[j] = rgb
self.lwir[j] = lwir
end
self.left_rgb = torch.Tensor(nb_points, self.channels, self.pSize, self.pSize)
self.left_lwir = torch.Tensor(nb_points, self.channels, self.pSize, self.pSize + self.half_range * 2)
self.right_lwir = torch.Tensor(nb_points, self.channels, self.pSize, self.pSize)
self.right_rgb = torch.Tensor(nb_points, self.channels, self.pSize, self.pSize + self.half_range * 2)
self.labels = torch.Tensor(nb_points, 1):fill(self.half_range+1)
for i = 1, nb_points do
-- get center of patches for left network
local id = self.locations[self.permutations[i]][1]
local type = self.locations[self.permutations[i]][2]
local x = self.locations[self.permutations[i]][3]
local y = self.locations[self.permutations[i]][4]
local right_x = self.locations[self.permutations[i]][5]
-- small patch rgb
self.left_rgb[i] = self.rgb[id - offset][{{}, {y - self.psz, y + self.psz}, {x - self.psz, x + self.psz}}]
-- big patch lwir
self.left_lwir[i] = self.lwir[id - offset][{{}, {y - self.psz, y + self.psz}, {right_x - self.psz - self.half_range, right_x + self.psz + self.half_range}}]
-- swap x coordinates rgb-lwir for right network
local tmp = x
x = right_x
right_x = tmp
-- small patch lwir
self.right_lwir[i] = self.lwir[id - offset][{{}, {y - self.psz, y + self.psz}, {x - self.psz, x + self.psz}}]
-- big patch rgb
self.right_rgb[i] = self.rgb[id - offset][{{}, {y - self.psz, y + self.psz}, {right_x - self.psz - self.half_range, right_x + self.psz + self.half_range}}]
end
collectgarbage()
end
function TestDataHandler:get_test()
return self.left_rgb:cuda(), self.left_lwir:cuda(), self.right_lwir:cuda(), self.right_rgb:cuda(), self.labels:cuda()
end
|
for i = 1, GetNumChannelMembers(7) do
c = GetChannelRosterInfo(7, i)
InviteUnit(c);
---GuildInvite(c);
print('Talked to: ' .. c);
end
|
local TrinketAlerter = BannZay.TrinketAlerter;
local AceConfig = LibStub("AceConfig-3.0");
local AceConfigDialog = LibStub("AceConfigDialog-3.0");
if TrinketAlerter == nil or AceConfig == nil or AceConfigDialog == nil then print("TrinketAlerter blizzard options will not be created as there dependencies to be satisfied"); return; end
local BlizzOptions = {};
local WotlkClassIds = {
"WARRIOR",
"PALADIN",
"HUNTER",
"ROGUE",
"PRIEST",
"DEATHKNIGHT",
"SHAMAN",
"MAGE",
};
local function AddHooks()
hooksecurefunc(TrinketAlerter, "OnInitialize", BlizzOptions.OnInitialize);
end
function BlizzOptions:OnInitialize()
AceConfig:RegisterOptionsTable("TrinketAlerter", BlizzOptions:BuildBlizzardOptions())
AceConfigDialog:AddToBlizOptions("TrinketAlerter", "TrinketAlerter")
end
local function SetOption(info, value)
local key = info.arg or info[#info]
if key == nil then
return;
end
TrinketAlerter.db[key] = value;
TrinketAlerter:ApplyDbSettings();
end
local function GetOption(info)
local key = info.arg or info[#info]
return TrinketAlerter.db[key];
end
function BlizzOptions:BuildBlizzardOptions()
local s = TrinketAlerter.Settings;
local options =
{
type = "group",
name = "TrinketAlerter (/ta or /trinketAlerter)",
plugins = {},
get = GetOption,
set = SetOption,
args = {}
}
options.args["lock"] =
{
type = "execute",
name = "Lock",
desc = "lock frames (/trinketAlerter lock)",
order = 1,
func = function(info, value) TrinketAlerter:Lock(); end,
}
options.args[s.AnimationTime] =
{
type = "range",
name = "Animation time",
desc = "The time frame flashes after trinket was used",
min =.4,
max = 6,
step =.2,
order = 2,
}
options.args[s.Scale] =
{
type = "range",
name = "Scale",
desc = "",
min =.3,
max = 6,
step =.1,
order = 3,
}
options.args[s.AnimationSpeed] =
{
type = "range",
name = "AnimationSpeed",
desc = "",
min =.05,
max = 1,
step =.05,
order = 4,
}
options.args["test"] =
{
type = "execute",
name = "Test",
desc = "",
order = 99,
func = function(info, value) TrinketAlerter:Lock(false); TrinketAlerter:FlashFreeFrame(WotlkClassIds[math.random(1, 8)]); end,
}
return options;
end
AddHooks(); |
Config = {}
Config.ZDiff = 2.0
Config.BlipSprite = 431
Config.Locale = 'en'
Config.EnableBlips = false
Config.ATMLocations = {
{ ['x'] = -386.733, ['y'] = 6045.953, ['z'] = 31.501},
{ ['x'] = -110.753, ['y'] = 6467.703, ['z'] = 31.784},
{ ['x'] = 155.4300, ['y'] = 6641.991, ['z'] = 31.784},
{ ['x'] = 174.6720, ['y'] = 6637.218, ['z'] = 31.784},
{ ['x'] = 1703.138, ['y'] = 6426.783, ['z'] = 32.730},
{ ['x'] = 1735.114, ['y'] = 6411.035, ['z'] = 35.164},
{ ['x'] = 1702.842, ['y'] = 4933.593, ['z'] = 42.051},
{ ['x'] = 1967.333, ['y'] = 3744.293, ['z'] = 32.272},
{ ['x'] = 1174.532, ['y'] = 2705.278, ['z'] = 38.027},
{ ['x'] = 2564.399, ['y'] = 2585.100, ['z'] = 38.016},
{ ['x'] = 2558.683, ['y'] = 349.6010, ['z'] = 108.050},
{ ['x'] = 2558.051, ['y'] = 389.4817, ['z'] = 108.660},
{ ['x'] = 1077.692, ['y'] = -775.796, ['z'] = 58.218},
{ ['x'] = 1139.018, ['y'] = -469.886, ['z'] = 66.789},
{ ['x'] = 1168.975, ['y'] = -457.241, ['z'] = 66.641},
{ ['x'] = 1153.884, ['y'] = -326.540, ['z'] = 69.245},
{ ['x'] = 236.4638, ['y'] = 217.4718, ['z'] = 106.840},
{ ['x'] = 265.0043, ['y'] = 212.1717, ['z'] = 106.780},
{ ['x'] = -164.568, ['y'] = 233.5066, ['z'] = 94.919},
{ ['x'] = -1827.04, ['y'] = 785.5159, ['z'] = 138.020},
{ ['x'] = -1409.39, ['y'] = -99.2603, ['z'] = 52.473},
{ ['x'] = -1215.64, ['y'] = -332.231, ['z'] = 37.881},
{ ['x'] = -2072.41, ['y'] = -316.959, ['z'] = 13.345},
{ ['x'] = -2975.72, ['y'] = 379.7737, ['z'] = 14.992},
{ ['x'] = -2962.60, ['y'] = 482.1914, ['z'] = 15.762},
{ ['x'] = -3144.13, ['y'] = 1127.415, ['z'] = 20.868},
{ ['x'] = -1305.40, ['y'] = -706.240, ['z'] = 25.352},
{ ['x'] = -717.614, ['y'] = -915.880, ['z'] = 19.268},
{ ['x'] = -526.566, ['y'] = -1222.90, ['z'] = 18.434},
{ ['x'] = 149.4551, ['y'] = -1038.95, ['z'] = 29.366},
{ ['x'] = -846.304, ['y'] = -340.402, ['z'] = 38.687},
{ ['x'] = -1216.27, ['y'] = -331.461, ['z'] = 37.773},
{ ['x'] = -56.1935, ['y'] = -1752.53, ['z'] = 29.452},
{ ['x'] = -273.001, ['y'] = -2025.60, ['z'] = 30.197},
{ ['x'] = 314.187, ['y'] = -278.621, ['z'] = 54.170},
{ ['x'] = -351.534, ['y'] = -49.529, ['z'] = 49.042},
{ ['x'] = -1570.197, ['y'] = -546.651, ['z'] = 34.955},
{ ['x'] = 33.232, ['y'] = -1347.849, ['z'] = 29.497},
{ ['x'] = 129.216, ['y'] = -1292.347, ['z'] = 29.269},
{ ['x'] = 289.012, ['y'] = -1256.545, ['z'] = 29.440},
{ ['x'] = 1686.753, ['y'] = 4815.809, ['z'] = 42.008},
{ ['x'] = -302.408, ['y'] = -829.945, ['z'] = 32.417},
{ ['x'] = 5.134, ['y'] = -919.949, ['z'] = 29.557},
{ ['x'] = -284.037, ['y'] = 6224.385, ['z'] = 31.187},
{ ['x'] = -135.165, ['y'] = 6365.738, ['z'] = 31.101},
{ ['x'] = -94.9690, ['y'] = 6455.301, ['z'] = 31.784},
{ ['x'] = 1821.917, ['y'] = 3683.483, ['z'] = 34.244},
{ ['x'] = 540.0420, ['y'] = 2671.007, ['z'] = 42.177},
{ ['x'] = 381.2827, ['y'] = 323.2518, ['z'] = 103.270},
{ ['x'] = 285.2029, ['y'] = 143.5690, ['z'] = 104.970},
{ ['x'] = 157.7698, ['y'] = 233.5450, ['z'] = 106.450},
{ ['x'] = -1205.35, ['y'] = -325.579, ['z'] = 37.870},
{ ['x'] = -2955.70, ['y'] = 488.7218, ['z'] = 15.486},
{ ['x'] = -3044.22, ['y'] = 595.2429, ['z'] = 7.595},
{ ['x'] = -3241.10, ['y'] = 996.6881, ['z'] = 12.500},
{ ['x'] = -3241.11, ['y'] = 1009.152, ['z'] = 12.877},
{ ['x'] = -538.225, ['y'] = -854.423, ['z'] = 29.234},
{ ['x'] = -711.156, ['y'] = -818.958, ['z'] = 23.768},
{ ['x'] = -256.831, ['y'] = -719.646, ['z'] = 33.444},
{ ['x'] = -203.548, ['y'] = -861.588, ['z'] = 30.205},
{ ['x'] = 112.4102, ['y'] = -776.162, ['z'] = 31.427},
{ ['x'] = 112.9290, ['y'] = -818.710, ['z'] = 31.386},
{ ['x'] = 119.9000, ['y'] = -883.826, ['z'] = 31.191},
{ ['x'] = -261.692, ['y'] = -2012.64, ['z'] = 30.121},
{ ['x'] = -254.112, ['y'] = -692.483, ['z'] = 33.616},
{ ['x'] = -1415.909, ['y'] = -211.825, ['z'] = 46.500},
{ ['x'] = -1430.122, ['y'] = -211.014, ['z'] = 46.500},
{ ['x'] = 287.645, ['y'] = -1282.646, ['z'] = 29.659},
{ ['x'] = 295.839, ['y'] = -895.640, ['z'] = 29.217},
{ ['x'] = -1315.73, ['y'] = -834.89, ['z'] = 16.96},
{ ['x'] = 89.75, ['y'] = 2.35, ['z'] = 68.31}
}
|
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- Editbox for Lua. Handles the overall setup of them, with functions
-- for managing them.
function IFEditbox_fnSetString(this,NewStr)
if(this.bPasswordMode) then
local ShowStr = string.rep("*", string.len(NewStr))
IFText_fnSetString(this.showtext,ShowStr)
else
IFText_fnSetString(this.showtext,NewStr)
end
this.CurStr = NewStr
IFEditbox_fnMoveCursor(this)
end
function IFEditbox_fnSetUString(this,NewUStr)
if(this.bPasswordMode) then
local ShowStr = string.rep("*", string.len(NewUStr) * 0.5)
IFText_fnSetString(this.showtext,ShowStr)
else
IFText_fnSetUString(this.showtext,NewUStr)
end
this.CurStr = ScriptCB_ununicode(NewUStr)
IFEditbox_fnMoveCursor(this)
end
function IFEditbox_fnGetString(this)
return this.CurStr
end
function IFEditbox_fnSetFont(this,NewFont)
IFText_fnSetFont(this.showtext,NewFont)
end
function IFEditbox_fnSetScale(this,HScale,VScale)
IFText_fnSetScale(this.showtext,HScale,VScale)
end
-- Moves the cursor to the appropriate location
function IFEditbox_fnMoveCursor(this)
local CurPixelLen = IFText_fnGetExtent(this.showtext)
IFObj_fnSetPos(this.cursor, this.cursor.xLeft + CurPixelLen - 2)
end
-- Adds one character to an editbox. Handles special chars like
-- delete, etc.
function IFEditbox_fnAddChar(this,iChar)
local Len = string.len(this.CurStr)
if(iChar == 8) then
-- Handle backspace
if(Len > 0) then
this.CurStr = string.sub(this.CurStr, 1, Len - 1)
IFEditbox_fnSetString(this,this.CurStr)
end
return
end
-- Ignore all other illegal, immoral, or fattening characters.
if((iChar < 32) or (iChar > 254)) then
return
end
local CurPixelLen = IFText_fnGetExtent(this.showtext)
if(((this.MaxLen) and (CurPixelLen >= this.MaxLen)) or
((this.MaxChars) and (Len >= this.MaxChars))) then
ifelm_shellscreen_fnPlaySound("shell_menu_error")
return
end
this.CurStr = this.CurStr .. string.char(iChar)
IFEditbox_fnSetString(this,this.CurStr)
end
-- Sets the hilight on things
function IFEditbox_fnHilight(this, bBright)
local NewTexture
if(bBright) then
NewTexture = "border_3a_pieces"
else
NewTexture = "border_3_pieces"
end
if(this.bClearOnHilightChange) then
IFEditbox_fnSetString(this,"")
end
-- hey, it's a hack!
if(this.bIsTheCheatBox and (ifs_missionselect)) then
if(ifs_missionselect.cheatOutput) then
IFObj_fnSetVis( ifs_missionselect.cheatOutput, nil )
end
end
gButtonWindow_fnSetTexture(this, NewTexture)
IFObj_fnSetVis(this.cursor,bBright)
IFEditbox_fnMoveCursor(this) -- just in case
end
-- Bounces the cursor
gEditbox_CurAlpha = 0.5
gEditbox_CurDir = 2
function IFEditbox_fnBounceCursor(this, fDt)
if(this.bSilentAndInvisible) then
return
end
gEditbox_CurAlpha = gEditbox_CurAlpha + fDt * gEditbox_CurDir
if(gEditbox_CurAlpha > 1) then
gEditbox_CurAlpha = 1
gEditbox_CurDir = -math.abs(gEditbox_CurDir)
elseif (gEditbox_CurAlpha < 0.3) then
gEditbox_CurAlpha = 0.3
gEditbox_CurDir = math.abs(gEditbox_CurDir)
end
IFObj_fnSetAlpha(this.cursor,gEditbox_CurAlpha)
end
-- Creates a new Editbox. This item is centered around the center of
-- what's passed in. Values in Template to be filled out:
--
-- width : overall width in pixels (of the background)
-- height : overall height in pixels
-- MaxChars : # of characters possible, nil for unlimited
-- MaxLen : math.max length (in pixels at current font), nil for unlimited
function NewEditbox(Template)
-- Fill in defaults in case parent didn't.
Template.width = Template.width or 100
Template.w = Template.width
Template.height = Template.height or 16
Template.h = Template.height
local temp
if(Template.bSilentAndInvisible) then
temp = NewIFContainer(Template)
else
temp = NewButtonWindow(Template)
end
-- {
-- x = Template.x,
-- y = Template.y,
-- ZPos = Template.ZPos,
-- w = Template.width,
-- width = Template.width,
-- h = Template.height,
-- height = Template.height,
-- }
temp.bHotspot = 1
temp.fHotspotX = Template.w * - 0.5
temp.fHotspotW = Template.w
temp.fHotspotY = Template.h * -0.5
temp.fHotspotH = Template.h
temp.text_offset_x = 16
temp.text_offset_width = -32
if(gPlatformStr == "PC") then
temp.text_offset_x = 16 - 6
temp.text_offset_width = -32 + 6
end
temp.showtext = NewIFText {
x = Template.x + Template.width * -0.5 + temp.text_offset_x,
y = Template.h * -0.5,
halign = "left",
valign = "vcenter",
textw = Template.width + temp.text_offset_width,
texth = Template.h,
font = "meu_myriadpro_small", -- Template.font
string = Template.string,
ustring = Template.ustring,
nocreatebackground = 1,
}
temp.cursor = NewIFText {
x = Template.x + Template.width * -0.5 + temp.text_offset_x,
y = Template.h * -0.5,
halign = "left",
valign = "vcenter",
textw = Template.width + temp.text_offset_width,
texth = Template.h,
font = "meu_myriadpro_small", -- Template.font
string = "_",
nocreatebackground = 1,
alpha = 0, -- invisible by default
ColorR = 255,
ColorG = 255,
ColorB = 0,
}
temp.cursor.xLeft = temp.cursor.x -- store this for later
temp.type = "editbox" -- change type for mouse code
temp.MaxChars = Template.MaxChars
temp.MaxLen = Template.MaxLen
temp.bPasswordMode = Template.bPasswordMode
if(Template.string) then
temp.CurStr = Template.string
elseif (Template.ustring) then
temp.CurStr = ScriptCB_ununicode(Template.ustring)
else
temp.CurStr = ""
end
return temp
end
|
-- Gnuplot specific settings
-- keymap('', '-', ':s/^/\#/<CR>:nohlsearch<CR>', {})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.